简体   繁体   English

如何在Selenium IDE中使用Javascript单击元素

[英]How to do click on element with Javascript in Selenium IDE

I want to do click on an element that it seems to be invisible to normal commands of Selenium driver and Selenium IDE. 我想点击一个看起来对Selenium驱动程序和Selenium IDE的常规命令不可见的元素。

Using Selenium Chromedriver with Python this command doesn't work: 使用Selenium Chromedriver和Python这个命令不起作用:

driver.find_element_by_xpath("//a[@onclick='abc.def(123,456789);']")

I need to use javascript to simulate the user click and it works in this way: 我需要使用javascript来模拟用户点击,它以这种方式工作:

driver.execute_script("arguments[0].click();", driver.find_element_by_xpath("//a[@onclick='abc.def(123,456789);']"))

So, I'd like to know how can I use javascript to simulate the user click on Selenium IDE?. 所以,我想知道如何使用javascript来模拟用户点击Selenium IDE? I've tried like this but is not working. 我试过这样但是没有用。

Command: execute script
Target: arguments[0].click();
Value: xpath=//a[@onclick='abc.def(123,456789);']

I hope make sense. 我希望有道理。 Thanks in advance. 提前致谢。

 driver.find_element_by_xpath("//a[@onclick='abc.def(123,456789);']").click();

Selenium总是使用javascript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM