Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add double click element keyword #146

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Examples/form-handler/click-element.robot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Click link
Click Button
Open browser to test page http://127.0.0.1:7272/basic-html-elements.html
Click Button id=get_ajax


Double Click Element
Open browser to test page http://127.0.0.1:7272/basic-html-elements.html
Double Click Element id=double_click_get_id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you and verify step for ensure that double click work as expect?
Due to some of library may not send mouse event as double click

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's great to add it as Alias Keyword


Click Image
Open browser to test page http://127.0.0.1:7272/basic-html-elements.html
Click Image id=gate
Expand Down
2 changes: 1 addition & 1 deletion Examples/form-handler/element-properties.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
*** Test Cases ***
Count elements
${No of h2} = Get Element Count css=h2
Should Be Equal As Numbers 14 ${No of h2}
Should Be Equal As Numbers 15 ${No of h2}

Count non existing element
Set Timeout 1s
Expand Down
4 changes: 4 additions & 0 deletions PuppeteerLibrary/ikeywords/ielement_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ async def upload_file(self, locator: str, file_path: str):
async def press_keys(self, locator: str, *keys: str):
pass

@abstractmethod
async def double_click_element(self, locator: str, noWaitAfter: str='False'):
pass

##############################
# Status
##############################
Expand Down
19 changes: 19 additions & 0 deletions PuppeteerLibrary/keywords/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ def press_keys(self, locator, *keys):
self.info(f"Sending key(s) {keys} to {locator} element.")
return self.loop.run_until_complete(self.get_async_keyword_group().press_keys(locator, *keys))

@keyword
def double_click_element(self, locator, noWaitAfter='False'):
"""Double clicks element identified by ``locator``.

The ``noWaitAfter`` argument specifies skip wait for animation after click.
Only support for webkit and safari (Puppeteer)

Example:

| `Double Click Element` | id:register | |
| `Double Click Element` | id:register | ${True} |
"""
self.info(f"Double Clicking element '{locator}'.")
self.loop.run_until_complete(self.get_async_keyword_group().double_click_element(
locator=locator,
noWaitAfter=noWaitAfter
))


##############################
# Status
##############################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ async def press_keys(self, locator: str, *keys: str):
for key in keys:
await element.press(key)

async def double_click_element(self, locator: str, noWaitAfter: str='False'):
noWaitAfter = str2bool(noWaitAfter)
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
await element.dblclick(
no_wait_after=noWaitAfter
)

##############################
# Status
##############################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ async def press_keys(self, locator: str, *keys: str):
for key in keys:
await element.press(key)

async def double_click_element(self, locator: str, noWaitAfter: str='False'):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
await element.dblclick()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puppeteer not support dblclick
plz change to click with clickCount 2



##############################
# Status
##############################
Expand Down
26 changes: 26 additions & 0 deletions demoapp/html/basic-html-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ <h2>Alert</h2>
<hr>
</div>

<div class="container">
<div class="row" style="margin-top: 20px;">
<h2>Double Click</h2>
</div>
<div class="row" style="margin-top: 20px;">
<button type="button" class="btn btn-primary" ondblclick="loadDocDblAjax()" id="double_click_get_id">
Double Click to Change Content
</button>
<span id="ajax-dblc-content">Content...</span>
<script type="text/javascript">
function loadDocDblAjax() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("ajax-dblc-content").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "contents/ajax_info.json?count=3", true);
xhttp.send();
}
</script>
</div>
<hr>
</div>

<div class="container">
<div class="row" style="margin-top: 20px;">
<h2>Browser Management</h2>
Expand Down