gpt4 book ai didi

Selenium 与 WebDriver,有什么明显的优势吗?

转载 作者:行者123 更新时间:2023-12-02 21:33:41 25 4
gpt4 key购买 nike

我从 SeleniumRC 迁移到 WebDriver 已有近两年了。但我不得不说,我并没有感觉到 webdriver 相对于 rc 有什么明显的优势。现在我有 200 多个针对网站的 C# 驱动程序测试用例。但是当我彻底运行它们进行回归测试时,我通常会得到 150 个通过和 50 多个失败/错误。第二次运行失败的测试用例后,很多都通过了,只有少数被证明是测试代码的问题。正如我所看到的,有时WebDriver确实执行得很慢,而我以前使用SeleniumRC时从未遇到过这种情况。结果,我开始怀疑是否有必要从 rc 迁移到 webdriver,因为我比以前花了更多的时间来验证错误和失败。

所以我的问题是,webdriver 相对于 rc 是否有任何优势,值得从 rc 迁移到 webdriver?如果是这样,您能告诉我吗?另外,说一下缺点。

最佳答案

Selenium RC 将 Javascript 注入(inject)页面以驱动交互。 Webdriver 直接与浏览器交互。注入(inject)额外的 Javascript 有缺点,Selenium HQ 网站对此说得相当清楚。

While Selenium was a tremendous tool, it wasn’t without its drawbacks. Because of its Javascript based automation engine and the security limitations browsers apply to Javascript, different things became impossible to do. To make things “worst”, webapps became more and more powerful over time, using all sorts of special features new browsers provide and making this restrictions more and more painful.

http://seleniumhq.org/docs/01_introducing_selenium.html#selenium-history

另一种思考方式是,测试添加了更多 JS 的页面,你并不是真正测试原始页面;而是测试一个添加了更多 JS 的页面。您正在测试修改后的页面。

关于Selenium 与 WebDriver,有什么明显的优势吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9781940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com