How can I scroll a web page in Mozilla Firefox using Selenium

0 votes
May 13, 2019 in Selenium by Rohan
3,222 views

1 answer to this question.

0 votes

Hi Rohan, steps to scroll a webpage in Mozilla Firefox using Selenium:

  1. Launch Eclipse IDE and open the existing package. For eg. "pageObjects"
  2. Right click on the "src" folder and create a new Class File "Scroll_Test" from New >Class.

    Selenium WebDriver- Scrolling a web page
     
  3. Now, write the below shown script in your editor and save the test script:
package pageObjects;

import org.openqa.selenium.JavascriptExecutor;  
import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.firefox.FirefoxDriver;  
import org.openqa.selenium.remote.DesiredCapabilities;  
  
public class Scroll_Test {  
  
    public static void main(String[] args) throws InterruptedException {  
                  System.setProperty("webdriver.gecko.driver","C:\\Users\\Abha_Rathour\\Downloads\\ExtractedFiles\\geckodriver-v0.24.0-win64\\geckodriver.exe" );  
              
            DesiredCapabilities capabilities = DesiredCapabilities.firefox();  
            capabilities.setCapability("marionette",true);  
            WebDriver driver= new FirefoxDriver(capabilities);  
          
        driver.navigate().to("https://www.edureka.co");   
        JavascriptExecutor js = (JavascriptExecutor)driver;  
        js.executeScript("scrollBy(0, 4500)");  
        
        Thread.sleep(3000);
        driver.close();
  
    }  
}  

Upon execution, the above test script will launch the Firefox browser and automate all the test scenarios.

answered May 14, 2019 by Pratibha
• 3,690 points

Related Questions In Selenium

0 votes
1 answer

How can I locate web elements from a web page using Selenium Webdriver?

Hey @Dushyant, Locating elements in WebDriver is ...READ MORE

answered May 29, 2019 in Selenium by Shreya
2,919 views
0 votes
2 answers

How to scroll a Web Page using coordinates of a WebElement in Selenium WebDriver ?

JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("window.scrollBy("X", " y ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
6,162 views
0 votes
1 answer

How can I locate inline elements from a web page using Selenium Webdriver?

Which specific element you are trying to ...READ MORE

answered Oct 10, 2019 in Selenium by Abha
• 28,140 points
4,102 views
0 votes
1 answer

How can I travel forward and back in a browser using selenium?

You can use the Navigate interface to ...READ MORE

answered Dec 31, 2018 in Selenium by Nabarupa
12,282 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,772 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,187 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,263 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,902 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP