package trails2110;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo01 {
WebDriver driver;
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "D:\\Eclipse\\Drivers\\chromedriver.exe");
System.out.println("1");
driver= new ChromeDriver();
System.out.println("2");
}
@After
public void tearDown() throws Exception {
driver.close();
}
@Test
public void test() {
String url= "www.hotstar.com";
System.out.println("3");
driver.get(url);
System.out.println("4");
String Title=driver.getTitle();
System.out.println(Title);
}
}在控制台中直到3点才能打印出来。我有最新版本的chrome和最新版本的chrome驱动程序。我尝试使用多个驱动程序都不起作用。我是不是遗漏了什么?
我可以使用以下代码路由到url
System.setProperty("webdriver.chrome.driver", "D:\\Eclipse\\Drivers\\chromedriver.exe");
WebDriver driver= new ChromeDriver();
String url = "https://www.google.com";
String script = "window.location = \'"+url+"\'";
((JavascriptExecutor) driver).executeScript(script);get()方法没有发生,而JavascriptExecutor发生了,有什么原因吗?
发布于 2021-10-21 22:40:21
您应该使用其协议声明URL。所以
String url= "www.hotstar.com";
url = "https://" + urlhttps://stackoverflow.com/questions/69668120
复制相似问题