我想在彈出窗口中只顯示當我移動鼠標光標時彈出的時間。然後將鼠標移到另一個點。我嘗試在osx和ubuntu上使用firefox和phantomjs。 Phantomjs從來沒有工作,與Firefox有時工作,有時它不,有時候movetoelement作品,movebyoffset不會。我嘗試了等待和睡眠功能,結果相同。頁面是ajax內容。當我嘗試點擊「href = javascript」按鈕時,我面臨同樣的問題。可能是什麼問題?Selenium:將鼠標移動到元素不起作用
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>
你能發佈你正在訪問這些信息的網址嗎? – Phillip
我編輯了這個問題,你可以在那裏看到。 – hzleonardo
有沒有其他元素與'content'類? – Phillip