您的位置:首页 > 其它

How to click a link / button implemented as a div or span element with WebDriver

2016-03-11 17:27 477 查看
http://sqa.stackexchange.com/questions/2918/how-to-click-a-link-button-implemented-as-a-div-or-span-element-with-webdriver

使用div实现了button和link

in my testing I need to click on a 'link' or a 'button' (actually it just looks like and functions as a link or a button) that is implemented as a div (or span) element. With Selenium IDE, I tried with either clickAt or mouseDown command, both worked fine to
successfully click that 'link' or 'button'. However, in WebDriver, it seems that currently there is no click_at method (using Python binding), can anyone please help me on this, or is there any workaround available? Thanks.

P.S. As an example, I noticed that in Gmail, the "COMPOSE" button is implemented as a div element.

Apologies - I don't know Python, but in C# I'm able to click elements with any tag by using
MoveToElement()
before
clicking. This way Webdriver is clicking based on location. For example:

new
Actions(driver).MoveToElement(mySpanElement).Click().Perform();


Something similar might work for Python.

Great thanks @SteveCZ, it is working in Python with similar method as:
<br/>ActionChains(driver).move_to_element(targetElement).click().perform()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: