Selenium webdriver highlight element before clicking

橙三吉。 提交于 2019-12-06 06:11:50

Selenium RC could do this but there is no direct API method to do this in WebDriver. Your options are:

1) Use the WebDriverBackedSelenium implementation in your language bindings to access the Highlight method.

2) Simply call some javascript using the JavascriptExecutor (or similar implementation in your language bindings) to do the job for you. This will mimic what Selenium RC/option 1 would achieve.

The Javascript to call exists here:

http://code.google.com/p/selenium/source/browse/javascript/selenium-core/scripts/htmlutils.js

The function to note is the highlight function. Just load this script using the JavascriptExecutor (search to find out how to do this in your programming language).

You can then compare this to see how the WebDriverBackedSelenium implementation in the Java API's are using it:

http://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/internal/seleniumemulation/Highlight.java

Use this, to do this same in your own code.

As a side note, the Selenium IDE for Firefox can highlight methods as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!