c# - 直接点击元素与通过 Action 类点击元素的区别

标签 c# selenium selenium-webdriver

我只想知道通过Action类点击webelement和直接点击有什么区别

假设我们在网页上有一个 button1

Actions action = new Actions(_driver);  
 action.MoveToElement(driver.FindElement(By.Id("button1")));
 action.Click().Build().Perform();

               VS  
driver.FindElement(By.Id("button1").Click();

以上两种说法有什么区别。

谢谢

最佳答案

您是否考虑过阅读 documentation

Actions类:

The user-facing API for emulating complex user gestures. Use this class rather than using the Keyboard or Mouse directly.

特别是 click方法:

Clicks at the current mouse location.

WebDriver.click方法:

Click this element. If this causes a new page to load, this method will attempt to block until the page has loaded.

关于c# - 直接点击元素与通过 Action 类点击元素的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28600313/

相关文章:

java - 使用 Selenium 和 Java 9 执行自动化测试时发生非法反射访问操作

java - Selenium WebDriver 单击输入元素上传文件卡住

java - 用显式等待替换隐式等待(selenium webdriver 和 java)

c# - 知道 RazorEngine 中的特定模板是否已经编译

c# - 出现 ASP 错误 : Mailbox unavailable. 服务器响应为 : Access denied - Invalid HELO name (See RFC2821 4. 1.1.1)

python - 如何使用 Python 在 Selenium Webdriver 中选择一个具有通用类名的元素?

ruby - 如何使用 Capybara 获取 HTML 表格行

c# - 测量 C# + Mono 中可用的内存量

C# - 从字符串、对象类型的字典中的对象获取数组值

selenium - 如何在 Firefox 中从 Katalon Studio 启动 Web 应用程序时自动进行身份验证