Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix--大于等于111版本的chrome webview切换web上下文失败,参考官方的方案进行修复 #341

Conversation

caofengbin
Copy link
Member

@caofengbin caofengbin commented May 11, 2023

Whether this PR is eventually merged or not, Sonic will thank you very much for your contribution.

无论此PR最终是否合并,Sonic组织都非常感谢您的贡献。

Checklist

  • The title starts with fix, fea, or doc. | 标题为fix、feat或doc开头。
  • I have checked that there are no duplicate pull requests with this request. | 我已检查没有与此请求重复的拉取请求。
  • I have considered and confirmed that this submission is valuable to others. | 我已经考虑过,并确认这份呈件对其他人很有价值。
  • I accept that this submission may not be used. | 我接受此提交可能不会被使用。

Description

本地chrome webview版本为112,切换webview上下文失败。

image

查看相关资料,为selenium自身的问题。

链接 Chrome 111 is not compatible with default HTTP Client 以及ChromeDriver 111.0.5563.19 unable to establish connection to chrome给的方案为

options.addArguments("--remote-allow-origins=*");

我这边测试发现没办法解决,

另外一个方案为stackoverflow上的, Java.io.IOException: Invalid Status code=403 text=Forbidden

引入selenium-http-jdk-client,并设置

System.setProperty("webdriver.http.factory", "jdk-http-client");

我这边测试是可以的。

@prlabeler prlabeler bot added the fix label May 11, 2023
Copy link
Member

@ZhouYixun ZhouYixun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不错!感谢贡献

@ZhouYixun
Copy link
Member

确认不会影响旧版本对吗?

说实话我还没遇过111版本的chromedriver,90以上都没,感谢覆盖到了

@caofengbin
Copy link
Member Author

低版本上有些问题,我再验证下哈,重新修改下

@ZhouYixun
Copy link
Member

低版本上有些问题,我再验证下哈,重新修改下

或者验证下版本大于等于111的才做你这次的优化

@caofengbin
Copy link
Member Author

低版本上有些问题,我再验证下哈,重新修改下

或者验证下版本大于等于111的才做你这次的优化

嗯嗯,主要是System.setProperty("webdriver.http.factory", "jdk-http-client");这个要在创建ChromeDriverService之前调用。那我就把 AndroidDeviceBridgeTool.getChromeDriver 中获取 chrome版本的逻辑单独抽取出来,做个工具方法吧

@caofengbin
Copy link
Member Author

我这边重新修改了下,仅针对>=111的版本下才开启jdk-http-client,在80,90和112的机器上都自测验证了下,初步看没撒问题了,辛苦帮忙review下哈

Copy link
Member

@ZhouYixun ZhouYixun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mg

@ZhouYixun ZhouYixun merged commit 7bb9164 into SonicCloudOrg:main May 12, 2023
1 check passed
@ZhouYixun
Copy link
Member

感谢你的付出,看下v2.5.0发布后会不会有用户有其他问题,我这边微信h5可以的

@caofengbin
Copy link
Member Author

感谢你的付出,看下v2.5.0发布后会不会有用户有其他问题,我这边微信h5可以的

嗯嗯,我这边也持续关注下这个问题

@caofengbin caofengbin deleted the feature/adaptation_chromedriver_high_version branch May 17, 2023 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants