簡體   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