当我在selenium webdriver中通过eclipse启动firefox时,我得到了about:blank& utm_content = firstrun url

时间:2016-04-20 18:42:30

标签: java selenium-webdriver

package packageselenium;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
public class Login {
static String URL = ExcelUtil.readSpecificCell("C:\\Users\\Rama\\Downloads\\Eclipse_Practice\\SeleniumDay1\\Newfolder\\TestData.xlsx", "Sheet1", "URL");
public static WebDriver driver;
public static void main(String[] args) throws Exception {
     driver=WebDriverUtilities.openbrowser(driver);
     driver.navigate().to(URL);
    // driver.manage().timeouts().implicitlyWait(2, TimeUnit.MILLISECONDS);
     //Thread.sleep(1000);
     //driver.get(URL);
     System.out.println("Entered URL as"+URL);
    return; 
}
}

能够启动浏览器。但是我在Excel工作表中提供的网址是" https://www.gmail.com"。当我调试能够获取URL值时。但是在启动浏览器之后能够看"关于:blank& utm_content = firstrun"而不是" https://www.gmail.com"。

1 个答案:

答案 0 :(得分:0)

请尝试以下代码,如果您能够在控制台上打印网址,请告诉我。

package packageselenium;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
public class Login {
static String URL;
public static WebDriver driver;
public static void main(String[] args) throws Exception {
URL = ExcelUtil.readSpecificCell("C:\\Users\\Rama\\Downloads\\Eclipse_Practice\\SeleniumDay1\\Newfolder\\TestData.xlsx", "Sheet1", "URL");
System.out.println("application URL "+URL)
driver=WebDriverUtilities.openbrowser(driver);
 driver.navigate().to(URL);
// driver.manage().timeouts().implicitlyWait(2, TimeUnit.MILLISECONDS);
 //Thread.sleep(1000);
 //driver.get(URL);
 System.out.println("Entered URL as"+URL);
return; 
 }
}