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 上?
uj5u.com熱心網友回復:
您應該使用其協議宣告 URL。所以
String url= "www.hotstar.com";
url = "https://" url
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/331709.html
標籤:硒
