C# Selenium 2/Webdriver-如何双击表格行(打开一个新窗口)
我正在将C#与Selenium 2.0/Webdriver结合使用,并尝试模拟双击表格行以打开新的浏览器窗口 我有两个问题:C# Selenium 2/Webdriver-如何双击表格行(打开一个新窗口),c#,webdriver,selenium-webdriver,C#,Webdriver,Selenium Webdriver,我正在将C#与Selenium 2.0/Webdriver结合使用,并尝试模拟双击表格行以打开新的浏览器窗口 我有两个问题: 在定位具有唯一类名的表行(即使用findelelement(By.classname(“…”)))后,应用click方法(或select/submit)不会执行任何操作,并抱怨无法对相关元素执行此类操作 如何在Selenium 2.0/Webdriver中执行双击 您应该单击表格单元格()元素 WebDriver中尚未实现双击。有关状态,请参阅。此外,本期评论还包含一个J
findelelement(By.classname(“…”)))
后,应用click方法(或select/submit)不会执行任何操作,并抱怨无法对相关元素执行此类操作
)元素(IJavaScriptExecutor)driver).executeScript("arguments[0].fireEvent('ondblclick');", cell);
from selenium.webdriver import ActionChains
action_chains = ActionChains(driver)
action_chians.double_click(on_element).perform()
对于Firefox和Chrome:
(IJavaScriptExecutor)driver).executeScript("var evt = document.createEvent('MouseEvents');" +
"evt.initMouseEvent('dblclick',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);" +
"arguments[0].dispatchEvent(evt);", cell);
其中,
单元格
是要在其上执行脚本的web元素。双击可以执行以下操作:
(IJavaScriptExecutor)driver).executeScript("arguments[0].fireEvent('ondblclick');", cell);
from selenium.webdriver import ActionChains
action_chains = ActionChains(driver)
action_chians.double_click(on_element).perform()
*其中,on_element=要双击的元素*
我使用python实现了这一点。它成功了:)+1-当开箱即用双击无法完成您希望它完成的任务时,它仍然是一个很好的选择。2017年,Mestil true的工作非常完美——双击td是让它为我工作的关键。