开发者

Using Selenium to 'click' on non-input or non-control elements

Has anyone been successful with getting Selenium to issue a mouse click on an element which is not associated with input, i.e. pl开发者_StackOverflowain text? I have tried using click() and click_at() methods, as well as fire_event(locator, event), where 'event' is 'onclick', or by using combination of 'onmousedown' and 'onmouseup' events. I have also tried preceding these events with an 'onmouseover' event. In my app, clicking on this 'plain text' triggers a call to a flash.swf routine. Thanks.


Have you tried adapting a Mouse Listener? In case you are extending Selenium using Java, here is a quick tutorial.


Have you tried fire_event(locator, 'click') instead of 'onclick'?


Have you tried tweaking fire event? As you are mentioning it as plain text locator of this should be like //p[contains(text(),'yourtext')] something like this. Try it once.


A native .click() event should work fine if your using Firefox 31.6.0 ESR (not a later version), or if your using Chrome. Keep in mind that for any event where a physical mouse click is not working for you (for whatever reason), you can still call a JavascriptExecutor to click the element (which is referred to as a synthetic non-native Selenium event).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜