繁体   English   中英

硒:将鼠标移到元素上不起作用

[英]Selenium: move mouse to element doesn't work

我想花一些时间在弹出窗口中,该弹出窗口仅在将鼠标指针移到该弹出窗口时才会显示。 然后将鼠标移到另一点。 我尝试在osx和ubuntu上使用firefox和phantomjs。 Phantomjs从不工作,在Firefox中有时工作而有时却不行,有时movetoelement工作,而movebyoffset不工作。 我也尝试了等待和睡眠功能,结果相同。 页面是ajax内容。 当我尝试单击“ href = javascript”按钮时,我也遇到了同样的问题。 可能是什么问题?

movetoelement=css(".content")
action = webdriver.ActionChains(browser)
action.move_to_element(movetoelement)
action.perform()
time = css('.time').text
print time
actionoffset = webdriver.ActionChains(browser)
actionoffset.move_by_offset(10,10)
actionoffset.perform()

它需要登录,因此我可以向您显示html。 我的css路径没有问题。 就像我说的,有时候它有用,有时候却没有。

> This is for the element to hover on.
> 
> <a class="tLink event ajaxify" href=“url"
> ajaxtarget="mainLeftContent”>contentbody</a>
> 
> This is for the button
> 
> <a id=“pressbutton" class="tButton large blue" href="javascript:"
> onclick="xcoupon.fn.openPreview()" bt-xtitle="" title=“">Continue</a>

您是否尝试过链接您的动作?

movetoelement=css(".content")
action = webdriver.ActionChains(browser)
actionoffset = webdriver.ActionChains(browser)   
action.move_to_element(movetoelement).actionoffset.move_by_offset(10,10).perform()

请注意,在浏览器窗口中移动鼠标会破坏这种测试。

暂无
暂无

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

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