简体   繁体   中英

URL does not open with WebDriver

My code is

package mentor.qa.selenium;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class WDDemo1 {

    public static void main( String[] args){
        WebDriver driver = new FirefoxDriver();         
        driver.get("http://www.google.com");
    }
}

I am using the latest java jar file 2.47.1 and Firefox 41.0.1. It starts Firefox but does not go to the link. How can I solve that?

Code is working but optimize imports.

I run your code with minuscule edit. It opens google website. Reverify if you have imported both selenium-java and selenium-server-standalone jar files in the build path.

package com.jayant.selenium;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SampleSelenium {
    public static void main( String[] args){
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
    }
}

Your code is perfect. It might be configuration issue ie use lower version of firefox with same code. It will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM