脚本问题或版本



当我尝试执行脚本时,没有收到任何错误或异常,但功能不起作用。有人能告诉我为什么会这样吗。

Selenium version: selenium-server-4.0.0-beta-2 version.
chrome supported version: Version 89.0.4389.114

代码

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import static org.openqa.selenium.support.locators.RelativeLocator.withTagName;
public class Relative Locator 
{
public static void main(String[] args) throws Interrupted Exception
{
System.setProperty("webdriver.chrome.driver", "C:\Users\Amitava\eclipse-workspace\SeleniumForthEdition\driver\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.rahulshettyacademy.com/angularpractice/");
WebElement nameEditBox =driver.findElement(By.cssSelector("[name='name']"));    
Thread.sleep(5000);
System.out.println(driver.findElement(withTagName("label").above(nameEditBox)).getText());
Thread.sleep(5000);
WebElement email =driver.findElement(By.xpath("//*[contains(text(),'Email')]"));    
Thread.sleep(8000);
System.out.println("selenium-server-4.0.0-beta-2");
driver.findElement(withTagName("input").below(email)).sendKeys("ami00@gmail.com");
}
}

控制台输出

Starting ChromeDriver 89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}) on port 10578
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1617949244.583][WARNING]: Timed out connecting to Chrome, retrying...
Apr 09, 2021 11:50:53 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Apr 09, 2021 11:50:55 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found exact CDP implementation for version 89
Name
selenium-server-4.0.0-beta-2


检查这两个:

  • 如何修复〔1573451709.039〕〔警告〕:连接Chrome超时,正在重试。。。同时使用chrome版本78和chrome驱动程序版本78.0.3904.70
  • 当使用Chrome浏览器运行WebDriver时,收到消息,";只允许本地连接";即使浏览器正常启动

这似乎更像是版本控制问题

请在初始化chrome驱动程序时使用以下代码。看起来它没有接收来自web协议的传入消息。

System.setProperty("webdriver.chrome.whitelistedIps", "");

相关内容

  • 没有找到相关文章

最新更新