Unable to perform click action in selenium python

前端 未结 1 1553
梦谈多话
梦谈多话 2020-12-16 23:55

I\'m writing a test script using selenium in python. I have a web-page containing a tree-view object like this:

<script

相关标签:
1条回答
  • 2020-12-17 00:18

    After some tries like .execute_script("changeTree();"), .submit(), etc, I have solved the issue by using the ActionChains class. Now, I can click in all elements that they have java-script events as onclick. The code that I have used is this:

    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get('someURL')
    el = driver.find_element_by_id("someid")
    webdriver.ActionChains(driver).move_to_element(el).click(el).perform()
    

    I don't know if it occurred just to me or what, but I found out that I should find the element right before the key command; otherwise the script does not perform the action. I think it would be related to staling elements or something like that; anyway, thanks all for their attention.

    0 讨论(0)
提交回复
热议问题