Double Click Calendar with Selenium NodeJS
https://imgur.com/bcKQIJr <-- Calendar Image
I have a calendar that requires a double click select dates. I'm working in Javascript, and the NodeJS Selenium-webdriver library has a pretty limited set of events, with no double click option... Do I need to incorporate another library for a double click feature or something? I've really hit a wall.
I know this code doesn't work, I've tried a little bit of everything. I just need to double click on a list of elements like the one below.
`el = driver.findElement(By.xpath("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]"));
el.click()
.then(_ => driver.sleep(250))
.then(_ => el.click())
`
I can see the clicks happening, so I know I have the element right and the event is happening at the right place/time... but I can't trigger the "selected" dates with what I've got.
javascript node.js selenium
add a comment |
https://imgur.com/bcKQIJr <-- Calendar Image
I have a calendar that requires a double click select dates. I'm working in Javascript, and the NodeJS Selenium-webdriver library has a pretty limited set of events, with no double click option... Do I need to incorporate another library for a double click feature or something? I've really hit a wall.
I know this code doesn't work, I've tried a little bit of everything. I just need to double click on a list of elements like the one below.
`el = driver.findElement(By.xpath("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]"));
el.click()
.then(_ => driver.sleep(250))
.then(_ => el.click())
`
I can see the clicks happening, so I know I have the element right and the event is happening at the right place/time... but I can't trigger the "selected" dates with what I've got.
javascript node.js selenium
images are not good way to show what exactly you doing, or trying to achieve, always add HTML snip so other can reproduce your problem
– Dev
Dec 27 '18 at 22:37
add a comment |
https://imgur.com/bcKQIJr <-- Calendar Image
I have a calendar that requires a double click select dates. I'm working in Javascript, and the NodeJS Selenium-webdriver library has a pretty limited set of events, with no double click option... Do I need to incorporate another library for a double click feature or something? I've really hit a wall.
I know this code doesn't work, I've tried a little bit of everything. I just need to double click on a list of elements like the one below.
`el = driver.findElement(By.xpath("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]"));
el.click()
.then(_ => driver.sleep(250))
.then(_ => el.click())
`
I can see the clicks happening, so I know I have the element right and the event is happening at the right place/time... but I can't trigger the "selected" dates with what I've got.
javascript node.js selenium
https://imgur.com/bcKQIJr <-- Calendar Image
I have a calendar that requires a double click select dates. I'm working in Javascript, and the NodeJS Selenium-webdriver library has a pretty limited set of events, with no double click option... Do I need to incorporate another library for a double click feature or something? I've really hit a wall.
I know this code doesn't work, I've tried a little bit of everything. I just need to double click on a list of elements like the one below.
`el = driver.findElement(By.xpath("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]"));
el.click()
.then(_ => driver.sleep(250))
.then(_ => el.click())
`
I can see the clicks happening, so I know I have the element right and the event is happening at the right place/time... but I can't trigger the "selected" dates with what I've got.
javascript node.js selenium
javascript node.js selenium
asked Dec 27 '18 at 22:12
Dave Kubo
82
82
images are not good way to show what exactly you doing, or trying to achieve, always add HTML snip so other can reproduce your problem
– Dev
Dec 27 '18 at 22:37
add a comment |
images are not good way to show what exactly you doing, or trying to achieve, always add HTML snip so other can reproduce your problem
– Dev
Dec 27 '18 at 22:37
images are not good way to show what exactly you doing, or trying to achieve, always add HTML snip so other can reproduce your problem
– Dev
Dec 27 '18 at 22:37
images are not good way to show what exactly you doing, or trying to achieve, always add HTML snip so other can reproduce your problem
– Dev
Dec 27 '18 at 22:37
add a comment |
2 Answers
2
active
oldest
votes
In case of some case (specific to browsers) this might not work for calendars. You might need to use javascript executer for this purpose. Below is some code for your reference.
let ele = document.evaluate("//th[@title='Chrome']", document, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('dblclick', true, true);
ele.dispatchEvent (clickEvent);
This should simulate double click on the element. Store this script in a variable (e.g. scrpit) and send to browser for execution using js executor. below is some sample code assuming variable script
has the js script
driver.executeScript(script).then(function(return_value) {
console.log('returned ', return_value)
});
This was the magic. Here's my working codevar el = 'let ele=document.evaluate("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;var clickEvent=document.createEvent("MouseEvents");clickEvent.initEvent("dblclick",!0,!0),ele.dispatchEvent(clickEvent);
driver.executeScript(el).then(function(return_value) { console.log('returned ', return_value) })
– Dave Kubo
Dec 28 '18 at 23:15
add a comment |
You should be able to use the actions()
method as described in this question's answer.
driver.actions().doubleClick(el).perform();
I did try that, but I get this error right at that line: UnknownCommandError: POST /session/3c399601-a7fb-4867-8903-bf01c13e420c/moveto did not match a known command at Object.throwDecodedError (C:UsersdavekDesktopProjectsSelenium_testnode_modulesselenium-webdriverliberror.js:514:15)
– Dave Kubo
Dec 28 '18 at 1:16
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53951386%2fdouble-click-calendar-with-selenium-nodejs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In case of some case (specific to browsers) this might not work for calendars. You might need to use javascript executer for this purpose. Below is some code for your reference.
let ele = document.evaluate("//th[@title='Chrome']", document, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('dblclick', true, true);
ele.dispatchEvent (clickEvent);
This should simulate double click on the element. Store this script in a variable (e.g. scrpit) and send to browser for execution using js executor. below is some sample code assuming variable script
has the js script
driver.executeScript(script).then(function(return_value) {
console.log('returned ', return_value)
});
This was the magic. Here's my working codevar el = 'let ele=document.evaluate("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;var clickEvent=document.createEvent("MouseEvents");clickEvent.initEvent("dblclick",!0,!0),ele.dispatchEvent(clickEvent);
driver.executeScript(el).then(function(return_value) { console.log('returned ', return_value) })
– Dave Kubo
Dec 28 '18 at 23:15
add a comment |
In case of some case (specific to browsers) this might not work for calendars. You might need to use javascript executer for this purpose. Below is some code for your reference.
let ele = document.evaluate("//th[@title='Chrome']", document, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('dblclick', true, true);
ele.dispatchEvent (clickEvent);
This should simulate double click on the element. Store this script in a variable (e.g. scrpit) and send to browser for execution using js executor. below is some sample code assuming variable script
has the js script
driver.executeScript(script).then(function(return_value) {
console.log('returned ', return_value)
});
This was the magic. Here's my working codevar el = 'let ele=document.evaluate("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;var clickEvent=document.createEvent("MouseEvents");clickEvent.initEvent("dblclick",!0,!0),ele.dispatchEvent(clickEvent);
driver.executeScript(el).then(function(return_value) { console.log('returned ', return_value) })
– Dave Kubo
Dec 28 '18 at 23:15
add a comment |
In case of some case (specific to browsers) this might not work for calendars. You might need to use javascript executer for this purpose. Below is some code for your reference.
let ele = document.evaluate("//th[@title='Chrome']", document, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('dblclick', true, true);
ele.dispatchEvent (clickEvent);
This should simulate double click on the element. Store this script in a variable (e.g. scrpit) and send to browser for execution using js executor. below is some sample code assuming variable script
has the js script
driver.executeScript(script).then(function(return_value) {
console.log('returned ', return_value)
});
In case of some case (specific to browsers) this might not work for calendars. You might need to use javascript executer for this purpose. Below is some code for your reference.
let ele = document.evaluate("//th[@title='Chrome']", document, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('dblclick', true, true);
ele.dispatchEvent (clickEvent);
This should simulate double click on the element. Store this script in a variable (e.g. scrpit) and send to browser for execution using js executor. below is some sample code assuming variable script
has the js script
driver.executeScript(script).then(function(return_value) {
console.log('returned ', return_value)
});
answered Dec 28 '18 at 22:40
neeraj jain
513
513
This was the magic. Here's my working codevar el = 'let ele=document.evaluate("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;var clickEvent=document.createEvent("MouseEvents");clickEvent.initEvent("dblclick",!0,!0),ele.dispatchEvent(clickEvent);
driver.executeScript(el).then(function(return_value) { console.log('returned ', return_value) })
– Dave Kubo
Dec 28 '18 at 23:15
add a comment |
This was the magic. Here's my working codevar el = 'let ele=document.evaluate("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;var clickEvent=document.createEvent("MouseEvents");clickEvent.initEvent("dblclick",!0,!0),ele.dispatchEvent(clickEvent);
driver.executeScript(el).then(function(return_value) { console.log('returned ', return_value) })
– Dave Kubo
Dec 28 '18 at 23:15
This was the magic. Here's my working code
var el = 'let ele=document.evaluate("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;var clickEvent=document.createEvent("MouseEvents");clickEvent.initEvent("dblclick",!0,!0),ele.dispatchEvent(clickEvent);
driver.executeScript(el).then(function(return_value) { console.log('returned ', return_value) })
– Dave Kubo
Dec 28 '18 at 23:15
This was the magic. Here's my working code
var el = 'let ele=document.evaluate("//div[@class='container']//table[2]//tbody[1]//tr[1]//td[3]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;var clickEvent=document.createEvent("MouseEvents");clickEvent.initEvent("dblclick",!0,!0),ele.dispatchEvent(clickEvent);
driver.executeScript(el).then(function(return_value) { console.log('returned ', return_value) })
– Dave Kubo
Dec 28 '18 at 23:15
add a comment |
You should be able to use the actions()
method as described in this question's answer.
driver.actions().doubleClick(el).perform();
I did try that, but I get this error right at that line: UnknownCommandError: POST /session/3c399601-a7fb-4867-8903-bf01c13e420c/moveto did not match a known command at Object.throwDecodedError (C:UsersdavekDesktopProjectsSelenium_testnode_modulesselenium-webdriverliberror.js:514:15)
– Dave Kubo
Dec 28 '18 at 1:16
add a comment |
You should be able to use the actions()
method as described in this question's answer.
driver.actions().doubleClick(el).perform();
I did try that, but I get this error right at that line: UnknownCommandError: POST /session/3c399601-a7fb-4867-8903-bf01c13e420c/moveto did not match a known command at Object.throwDecodedError (C:UsersdavekDesktopProjectsSelenium_testnode_modulesselenium-webdriverliberror.js:514:15)
– Dave Kubo
Dec 28 '18 at 1:16
add a comment |
You should be able to use the actions()
method as described in this question's answer.
driver.actions().doubleClick(el).perform();
You should be able to use the actions()
method as described in this question's answer.
driver.actions().doubleClick(el).perform();
answered Dec 27 '18 at 22:33
MPawlak
44029
44029
I did try that, but I get this error right at that line: UnknownCommandError: POST /session/3c399601-a7fb-4867-8903-bf01c13e420c/moveto did not match a known command at Object.throwDecodedError (C:UsersdavekDesktopProjectsSelenium_testnode_modulesselenium-webdriverliberror.js:514:15)
– Dave Kubo
Dec 28 '18 at 1:16
add a comment |
I did try that, but I get this error right at that line: UnknownCommandError: POST /session/3c399601-a7fb-4867-8903-bf01c13e420c/moveto did not match a known command at Object.throwDecodedError (C:UsersdavekDesktopProjectsSelenium_testnode_modulesselenium-webdriverliberror.js:514:15)
– Dave Kubo
Dec 28 '18 at 1:16
I did try that, but I get this error right at that line: UnknownCommandError: POST /session/3c399601-a7fb-4867-8903-bf01c13e420c/moveto did not match a known command at Object.throwDecodedError (C:UsersdavekDesktopProjectsSelenium_testnode_modulesselenium-webdriverliberror.js:514:15)
– Dave Kubo
Dec 28 '18 at 1:16
I did try that, but I get this error right at that line: UnknownCommandError: POST /session/3c399601-a7fb-4867-8903-bf01c13e420c/moveto did not match a known command at Object.throwDecodedError (C:UsersdavekDesktopProjectsSelenium_testnode_modulesselenium-webdriverliberror.js:514:15)
– Dave Kubo
Dec 28 '18 at 1:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53951386%2fdouble-click-calendar-with-selenium-nodejs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
images are not good way to show what exactly you doing, or trying to achieve, always add HTML snip so other can reproduce your problem
– Dev
Dec 27 '18 at 22:37