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

0 votes
May 13 in Selenium by Rohan
119 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 13 by Pratibha
• 2,780 points

Related Questions In Selenium

0 votes
1 answer
0 votes
0 answers

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

Below is my code: driver.get("https://www.google.com"); driver.findElement(By.xpath("//*[@id='gbwa']/div/a")).click(); Thread.sleep(4000); driver.findElement(By.cssSelector("#yDmH0d > c-wiz > ...READ MORE

22 hours ago in Selenium by anonymous
• 120 points

edited 16 hours ago by Omkar 13 views
0 votes
1 answer
0 votes
1 answer

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,090 points
567 views
0 votes
1 answer
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,130 points
895 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
559 views
0 votes
1 answer
0 votes
1 answer