Timed out connecting to Chrome, retrying… error using ChromeDriver 2.43 and Chrome through Selenium

huangapple go评论77阅读模式
英文:

Timed out connecting to Chrome, retrying... error using ChromeDriver 2.43 and Chrome through Selenium

问题

我现在甚至不确定在这一点上该做什么控制台中没有错误日志只有我放在脚本中的记录器消息

当我到达创建仪表板构造函数的代码行时它会终止测试并将其声明为失败最后记录的消息总是即将开始查找”。

在发布这个问题之前我甚至清空了整个构造函数注释掉了所有代码删除了驱动程序参数只是在其中放了一个打印语句),当我在类内部调用打印方法时脚本在创建构造函数的地方失败了

我不明白发生了什么我可能忽略了一些非常明显的东西我得到了失败的结果但在控制台中也没有看到具体的错误消息

这是我试图运行的测试用例

以下是我的 DashBoard 页面对象

控制台错误
英文:

I'm honestly not even sure what to do at this point I'm not getting any error logs in the console just the logger messages that I've put into the scripts.

When I get to the line of code where I create the Dashboard Constructor it terminates the test and declares it a failure, last logged message is always "About to start looking"

I even gutted the entire constructor(commented out all code, removed the driver parameter, and just put a print statement in it) before posting this question and when I called the print method within the class the script failed at the line where the creation of the constructor happened.

I don't understand what's going on I could be missing something very obvious. I get failure but I don't necessarily see a specific error message in the console either.

Here is the test case im attempting to run:

package com.symphio.testCases;
import java.util.concurrent.TimeUnit;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.symphio.pageObjects.Dashboard;
import com.symphio.pageObjects.loginSymphio;


public class TC_Dashboard_Search_002 extends BaseClass{

	
	@Test
	public void searchForTile() throws InterruptedException {
		
		logger.info("Connected to "+ baseURL);
		driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
				
		loginSymphio login = new loginSymphio(driver);
		//logs in
		login.setUserName(userName);
		logger.info("entered username");
		login.setPassWord(passWord);
		logger.info("entered password");
		login.pressSubmit();
		logger.info("button pressed");
		
		
		//searches for tile
		Thread.sleep(3000);


		logger.info("about to start looking");
		Dashboard dashboard = new Dashboard(driver);
		dashboard.mouseMover();
		logger.info("found Icon");
		dashboard.searchBarText(searchText);
		logger.info("input text");
		dashboard.tileClick();		
		logger.info("clicked");
				
	}
}

Here is my DashBoard pageObject

package com.symphio.pageObjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class Dashboard {
	WebDriver driver;

	public Dashboard(WebDriver driver) {
		this.driver = driver;
		PageFactory.initElements(driver, this);		
		
	} 
		
	@FindBy(className="search-container")
	WebElement searchImg;
	
	@FindBy(xpath="//input[@type='search']")
	WebElement searchText;
	
	@FindBy(xpath="//input[contains(@class,'mat-card'), and contains(@class, 'mat-focus-indicator'), and contains(@class, 'arrangement-card')]")
	WebElement tileBox;
	
	
	Actions actions = new Actions(driver);

	public void mouseMover() {
	Actions mouseOverOnElement = actions.moveToElement(searchImg);
	mouseOverOnElement.perform();
	
	}
	
	public void searchBarText(String text) {
		searchText.sendKeys(text);
				
	}
	
	public void tileClick() {
		tileBox.click();
		
		
	}
	
}

Console error:

Timed out connecting to Chrome, retrying… error using ChromeDriver 2.43 and Chrome through Selenium

答案1

得分: 0

这里的问题在于Dashboard类中的Driver尚未进行初始化。

尝试将Dashboard扩展为BaseClass。

public class Dashboard extends BaseClass {
    
    public Dashboard(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver, this);  

}   
英文:

I think the problem here is that the Driver is not yet initialize in the DashBoard Class.

try to extend the DashBoard into BaseClass.

public class Dashboard extends BaseClass {
    
    public Dashboard(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver, this);  

}   

答案2

得分: 0

这个错误信息...

...【警告】:连接到 Chrome 超时,正在重试...
...org.openqa.selenium.remote.ProtocolHandshake createSession
信息:检测到方言:OSS

...意味着你正在使用的ChromeDriver / [tag:google-chrome] 组合不是最近的版本,因为当前的 ChromeDriver 实现遵循 WebDriver W3C 规范,初始日志反映出:

只允许本地连接。
请保护 ChromeDriver 和相关测试框架使用的端口,以防止恶意代码访问。
2019 年 11 月 5 日 下午 3:41:53 org.openqa.selenium.remote.ProtocolHandshake createSession
信息:检测到方言:W3C

因此,你的主要问题是你正在使用的二进制文件版本之间的不兼容性,如下所示:

>支持 Chrome v69-71

>支持 Chrome 版本 84

所以 ChromeDriver v2.43Chrome 浏览器 v84.0 之间存在明显的不匹配。


解决方案

确保:

  • JDK 升级到当前版本 JDK 8u251
  • Selenium 升级到当前版本 Version 3.141.59
  • ChromeDriver 更新到当前版本 ChromeDriver v84.0
  • Chrome 更新到当前的 Chrome 版本 84.0(根据 ChromeDriver v84.0 发布说明)。
  • 如果你的基础 Web Client 版本过旧,则卸载它并安装一个最近的 GA 和发布版本的 Web Client
  • 通过你的 IDE 清理你的 项目工作区,并只使用所需的依赖重新构建你的项目。
  • 进行一次 系统重启
  • 非 root 用户身份执行你的 @Test
  • 总是在 tearDown(){} 方法中调用 driver.quit(),以优雅地关闭和销毁 WebDriverWeb Client 实例。

参考资料

你可以在以下讨论中找到一些相关的详细讨论:

英文:

This error message...

...[WARNING]: Timed out connecting to Chrome, retrying...
...org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

...implies that implies that the ChromeDriver /[tag:google-chrome] combo you are using is not the recent one as the current implementation of ChromeDriver follows WebDriver W3C specifications and initial logs reflects:

Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Nov 05, 2019 3:41:53 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C	

So your main issue is the incompatibility between the version of the binaries you are using as follows:

  • You are using chromedriver=2.43
  • Release Notes of chromedriver=2.43 clearly mentions the following :

>Supports Chrome v69-71

  • Possibly you are using the latest chrome=84.0
  • Release Notes of ChromeDriver v84.0 clearly mentions the following :

>Supports Chrome version 84

So there is a clear mismatch between ChromeDriver v2.43 and the Chrome Browser v84.0


Solution

Ensure that:

  • JDK is upgraded to current levels JDK 8u251.
  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v84.0 level.
  • Chrome is updated to current Chrome Version 84.0 level. (as per ChromeDriver v84.0 release notes)
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Reference

You can find a couple of relevant detailed discussions in:

huangapple
  • 本文由 发表于 2020年8月16日 14:08:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/63433695.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定