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

huangapple 未分类评论47阅读模式
英文:

Invoke a page by onclick() event using webdriver(selenium)

问题

我想使用网络驱动程序(selenium)根据onclick事件调用页面。

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

所以有人可以帮我解决这个问题,将会很棒。

提前谢谢!

英文:

I want to invoke the page based on the onclick event using a web driver(selenium).

&lt;img src=&quot;active.png&quot; class=&quot;default-logo avatar-image&quot; onclick=&quot;custom(event)&quot;&gt;

So can anybody help me with the solution it will be great.

Thanks ahead!

答案1

得分: 0

这里有一个示例作为范例:

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

通过这种方式,您将会找到一个具有 onclick 属性,且属性值 包含(这就是 *= 的意思)custom(event) 的 img 元素类型。

英文:

Here is a sample as an example:

driver.find_element_by_css_selector(&quot;img[onclick*=custom(event)]&quot;).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).

huangapple
  • 本文由 发表于 2020年5月4日 20:44:27
  • 转载请务必保留本文链接:https://java.coder-hub.com/61592505.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定