简体   繁体   English

使用 webdriver(selenium) 通过 onclick() 事件调用页面

[英]Invoke a page by onclick() event using webdriver(selenium)

I want to invoke the page based on the onclick event using a web driver(selenium).我想使用 web 驱动程序(硒)基于onclick事件调用页面。

<img src="active.png" class="default-logo avatar-image" onclick="custom(event)">

So can anybody help me with the solution it will be great.所以任何人都可以帮助我解决这个问题,它会很棒。

Thanks ahead!提前谢谢!

Here is a sample as an example:以下是一个示例:

driver.find_element_by_css_selector("img[onclick*=custom(event)]").click();

In this way, you will find an element type of img that has onclick attribute that contains (this is what *= means) this: custom(event) .通过这种方式,您会找到一个元素类型为 img 的元素类型,它具有onclick属性,其中包含(这是*=的意思): custom(event)

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

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