Want to move down using scrollbar selenium webdriver
I need to move down using scrollbar on a web page using selenium webdriver
I used following code
Actions dragger = new Actions(driver);
WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
int numberOfPixelsToDragTheScrollbarDown = 5000;
dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();
still its not moving down...xpath is changing as per position of scrollbar...
c# selenium
add a comment |
I need to move down using scrollbar on a web page using selenium webdriver
I used following code
Actions dragger = new Actions(driver);
WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
int numberOfPixelsToDragTheScrollbarDown = 5000;
dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();
still its not moving down...xpath is changing as per position of scrollbar...
c# selenium
add a comment |
I need to move down using scrollbar on a web page using selenium webdriver
I used following code
Actions dragger = new Actions(driver);
WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
int numberOfPixelsToDragTheScrollbarDown = 5000;
dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();
still its not moving down...xpath is changing as per position of scrollbar...
c# selenium
I need to move down using scrollbar on a web page using selenium webdriver
I used following code
Actions dragger = new Actions(driver);
WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
int numberOfPixelsToDragTheScrollbarDown = 5000;
dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();
still its not moving down...xpath is changing as per position of scrollbar...
c# selenium
c# selenium
edited Nov 22 '18 at 2:55
ivan_pozdeev
19.8k85294
19.8k85294
asked Dec 27 '13 at 6:36
Prasad DinPrasad Din
352312
352312
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.
WebElement element = driver.findElement(By.id("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
//do anything you want with the element
not working......
– Prasad Din
Dec 27 '13 at 7:36
what is the element you are trying to find?
– Amith
Dec 27 '13 at 7:44
its a text area....
– Prasad Din
Dec 27 '13 at 8:29
can you provide the html for this?
– Amith
Dec 27 '13 at 8:32
1
This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...
– djangofan
Dec 29 '13 at 20:30
|
show 4 more comments
My code is in python..hope it might help you and you can reproduce the same to java
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).perform()
actionChains.move_by_offset(0,5000).perform()
actionChains.release()
The above code can be simplified as
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()
add a comment |
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("window.scrollBy(0,100)");
add a comment |
By
scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
WebElement scrollUp = driver.findElement(scroll);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
For scroll up:
scrollUp.sendKeys(Keys.PAGE_DOWN);
add a comment |
For Java the code is below:
public void moveOverElement(WebElement element)
{
Actions actions = new Actions(driver);
actions.clickAndHold(element).moveByOffset(0,5000).release().perform();
}
For definition WebElement, for the webelement you have to define only the path:
@FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")
private WebElement createdQABoxElement;
add a comment |
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%2f20796053%2fwant-to-move-down-using-scrollbar-selenium-webdriver%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.
WebElement element = driver.findElement(By.id("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
//do anything you want with the element
not working......
– Prasad Din
Dec 27 '13 at 7:36
what is the element you are trying to find?
– Amith
Dec 27 '13 at 7:44
its a text area....
– Prasad Din
Dec 27 '13 at 8:29
can you provide the html for this?
– Amith
Dec 27 '13 at 8:32
1
This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...
– djangofan
Dec 29 '13 at 20:30
|
show 4 more comments
If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.
WebElement element = driver.findElement(By.id("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
//do anything you want with the element
not working......
– Prasad Din
Dec 27 '13 at 7:36
what is the element you are trying to find?
– Amith
Dec 27 '13 at 7:44
its a text area....
– Prasad Din
Dec 27 '13 at 8:29
can you provide the html for this?
– Amith
Dec 27 '13 at 8:32
1
This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...
– djangofan
Dec 29 '13 at 20:30
|
show 4 more comments
If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.
WebElement element = driver.findElement(By.id("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
//do anything you want with the element
If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.
WebElement element = driver.findElement(By.id("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
//do anything you want with the element
answered Dec 27 '13 at 7:24
AmithAmith
4,91862442
4,91862442
not working......
– Prasad Din
Dec 27 '13 at 7:36
what is the element you are trying to find?
– Amith
Dec 27 '13 at 7:44
its a text area....
– Prasad Din
Dec 27 '13 at 8:29
can you provide the html for this?
– Amith
Dec 27 '13 at 8:32
1
This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...
– djangofan
Dec 29 '13 at 20:30
|
show 4 more comments
not working......
– Prasad Din
Dec 27 '13 at 7:36
what is the element you are trying to find?
– Amith
Dec 27 '13 at 7:44
its a text area....
– Prasad Din
Dec 27 '13 at 8:29
can you provide the html for this?
– Amith
Dec 27 '13 at 8:32
1
This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...
– djangofan
Dec 29 '13 at 20:30
not working......
– Prasad Din
Dec 27 '13 at 7:36
not working......
– Prasad Din
Dec 27 '13 at 7:36
what is the element you are trying to find?
– Amith
Dec 27 '13 at 7:44
what is the element you are trying to find?
– Amith
Dec 27 '13 at 7:44
its a text area....
– Prasad Din
Dec 27 '13 at 8:29
its a text area....
– Prasad Din
Dec 27 '13 at 8:29
can you provide the html for this?
– Amith
Dec 27 '13 at 8:32
can you provide the html for this?
– Amith
Dec 27 '13 at 8:32
1
1
This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...
– djangofan
Dec 29 '13 at 20:30
This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...
– djangofan
Dec 29 '13 at 20:30
|
show 4 more comments
My code is in python..hope it might help you and you can reproduce the same to java
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).perform()
actionChains.move_by_offset(0,5000).perform()
actionChains.release()
The above code can be simplified as
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()
add a comment |
My code is in python..hope it might help you and you can reproduce the same to java
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).perform()
actionChains.move_by_offset(0,5000).perform()
actionChains.release()
The above code can be simplified as
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()
add a comment |
My code is in python..hope it might help you and you can reproduce the same to java
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).perform()
actionChains.move_by_offset(0,5000).perform()
actionChains.release()
The above code can be simplified as
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()
My code is in python..hope it might help you and you can reproduce the same to java
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).perform()
actionChains.move_by_offset(0,5000).perform()
actionChains.release()
The above code can be simplified as
actionChains = ActionChains(driver)
option=driver.find_element_by_class_name("mCSB_dragger_bar")
actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()
answered Dec 27 '13 at 9:39
Mahesh Reddy AtlaMahesh Reddy Atla
301312
301312
add a comment |
add a comment |
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("window.scrollBy(0,100)");
add a comment |
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("window.scrollBy(0,100)");
add a comment |
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("window.scrollBy(0,100)");
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("window.scrollBy(0,100)");
answered Feb 3 '14 at 11:00
SATYASATYA
373
373
add a comment |
add a comment |
By
scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
WebElement scrollUp = driver.findElement(scroll);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
For scroll up:
scrollUp.sendKeys(Keys.PAGE_DOWN);
add a comment |
By
scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
WebElement scrollUp = driver.findElement(scroll);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
For scroll up:
scrollUp.sendKeys(Keys.PAGE_DOWN);
add a comment |
By
scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
WebElement scrollUp = driver.findElement(scroll);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
For scroll up:
scrollUp.sendKeys(Keys.PAGE_DOWN);
By
scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
WebElement scrollUp = driver.findElement(scroll);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
scrollUp.sendKeys(Keys.PAGE_DOWN);
For scroll up:
scrollUp.sendKeys(Keys.PAGE_DOWN);
edited Mar 27 '15 at 12:53
JoelC
2,46383133
2,46383133
answered Mar 27 '15 at 12:08
chandrasekarchandrasekar
1
1
add a comment |
add a comment |
For Java the code is below:
public void moveOverElement(WebElement element)
{
Actions actions = new Actions(driver);
actions.clickAndHold(element).moveByOffset(0,5000).release().perform();
}
For definition WebElement, for the webelement you have to define only the path:
@FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")
private WebElement createdQABoxElement;
add a comment |
For Java the code is below:
public void moveOverElement(WebElement element)
{
Actions actions = new Actions(driver);
actions.clickAndHold(element).moveByOffset(0,5000).release().perform();
}
For definition WebElement, for the webelement you have to define only the path:
@FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")
private WebElement createdQABoxElement;
add a comment |
For Java the code is below:
public void moveOverElement(WebElement element)
{
Actions actions = new Actions(driver);
actions.clickAndHold(element).moveByOffset(0,5000).release().perform();
}
For definition WebElement, for the webelement you have to define only the path:
@FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")
private WebElement createdQABoxElement;
For Java the code is below:
public void moveOverElement(WebElement element)
{
Actions actions = new Actions(driver);
actions.clickAndHold(element).moveByOffset(0,5000).release().perform();
}
For definition WebElement, for the webelement you have to define only the path:
@FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")
private WebElement createdQABoxElement;
answered Feb 27 '18 at 12:32
Marius GolbanMarius Golban
13
13
add a comment |
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.
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%2f20796053%2fwant-to-move-down-using-scrollbar-selenium-webdriver%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
