Jump to content
Changes to the Jaspersoft community edition download ×
  • Selenium installation in Eclipse and launch a website using navigate().to() method


    Hi ,

    This tutorial is intended to written for beginners and in this example, we would see how to set-up and launch a website in chrome browser (for example: https://jasper-bi-suite.blogspot.com/) using java selenium.

    1. Download Eclipse zip from  https://www.eclipse.org/downloads/
    2. Install java 1.8 or later and set path & class path in windows os.
    3. Download suitable chromedriver.exe from https://chromedriver.chromium.org/downloads
          NOTE : This example is tested on : Version 81.0.4044.138 (Official Build) (64-bit)
    4. Download selenium jar files and configure in Eclipse Build Path as (Referenced Libraries)
          https://www.selenium.dev/downloads/
    5. Write FirstTestCase.java class with the code shown in below.
    6. Run as "Java Applicaiton".

    In the java class, ensure to have the following : 
    1)  System set property  -  using this call the chromedriver.exe
    2)  Declaring driver - driver declaration
    3)  navigate().to - method to navigate to a given site.
    4)     ChromeOptions options = new ChromeOptions();
             .......... Google Chrome Browser Options.............
            driver = new ChromeDriver(options);

    Watch this ~15 sec video for execution of this case.



    import java.util.concurrent.TimeUnit;
    /**
    * @author Sadakar Pochampalli
    */
    import org.openqa.selenium.PageLoadStrategy;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;

    public class FirstTestCase {

    public static void main(String[] args) {

    System.setProperty("webdriver.chrome.driver", "D:\\006_trainings\\chromedriver_win32\\chromedriver.exe");

    WebDriver driver ;

    ChromeOptions options = new ChromeOptions();

    //options.addArguments("--headless");
    options.addArguments("--disable-gpu");
    options.addArguments("start-maximized");
    options.setPageLoadStrategy(PageLoadStrategy.NONE);
    options.addArguments("--allow-insecure-localhost");
    options.addArguments("--allow-running-insecure-content");
    options.addArguments("--ignore-certificate-errors");
    options.addArguments("--no-sandbox");
    options.addArguments("--window-size=1280,1000");
    options.setCapability("acceptSslCerts", true);
    options.setCapability("acceptInsecureCerts", true);
      driver = new ChromeDriver(options);

    driver.navigate().to("https://jasper-bi-suite.blogspot.com/");
    driver.manage().window().maximize();

    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    //driver.close();

    }
    }


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...