我对编程有点陌生,我尝试执行以下代码,但是chrome页面正在加载,但是没有执行,并且我遇到以下错误。
Starting ChromeDriver 72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38) on port 27651
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Apr 19, 2019 12:23:41 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
我的配置 Windows 10,Chrome驱动程序V72和Selenium-3.141.59
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class MyClass {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\ADMIN\\Desktop\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://demo.guru99.com/test/newtours/";
String expectedTitle = "Welcome: Mercury Tours";
String actualTitle = "";
actualTitle = driver.getTitle();
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
driver.close();
}
}
答案 0 :(得分:0)
Detected dialect: OSS
日志级别为INFO
。它不会阻止您的测试运行。 Test Failed
中打印。 baseUrl
变量中的URL。在获取页面标题之前,您应该先获取页面。否则,它将不会为您提供所需的页面标题。Test Passed!
driver.get(baseUrl);
actualTitle = driver.getTitle();