2011-05-02 1 views
8

ActionChainsのmove_to_elementを使用してマウスオーバーイベントをトリガーしようとしましたが、動作させることができませんでした。どんな助けもありがとうございます。ありがとう。WebdriverのActionChains(pythonバインディング)を使っている人はいますか?

+0

)((actions.move_to_elementを使用することができた)とactions.click代わりactor.py試してみてください。https://gist.github.com/2036553 - それはあなたが直接代わりにアクションを呼び出すことができますそれらを格納し、次に '実行'を呼び出します。 –

答えて

7

私は今日もPythonのActionChainsをお手伝いしており、double_clickはクリックだけでは動作しないことに気付きました。だからあなたのコードはどのように見えますか?アクションを変更するには、実行する必要があります。

def setUp(self): 
    self.webdriver = webdriver.Ie() 
    self.mouse = webdriver.ActionChains(self.webdriver) 
    self.webdriver.get("http://foo") 

def test_webdriver(self): 
    mouse = self.mouse 
    wd = self.webdriver 
    wd.implicitly_wait(10) 
    element = wd.find_element_by_xpath("//div[@title='Create Page']") 
    mouse.move_to_element(element).perform() 
6
from selenium.webdriver.common.action_chains import ActionChains 

ActionChains(drivers).move_to_element(drivers.find_element_by_id('element_id')).click().perform() 

あなたが任意の値を選択したい場合は、

menu1 = drivers.find_element_by_xpath('html/path/of/select/box') 
sub_menu0 = drivers.find_element_by_xpath('html/path/of/selected/option') 
clickon = drivers.find_element_by_xpath(path/of/option/where/you/want/to/click) 
action = ActionChains(drivers) 
action.move_to_element(menu1) 
action.move_to_element(sub_menu0) 
action.click(clickon) 
action.perform() 
+0

'drivers'は貧弱な命名規則でなければなりません – User

0

私はセレンからactionchainsをインポートするまで、私はActionChainsが定義されていないエラーを取得しました。それから私は

from selenium.webdriver.common.action_chains import ActionChains 
関連する問題