How to access to 'rect' type element through Selenium-Python

后端 未结 2 1075
醉酒成梦
醉酒成梦 2020-11-30 15:03

There is a rect object in the dom:

<         


        
2条回答
  •  日久生厌
    2020-11-30 15:38

    Use Action class or JavaScript Executor.

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as ec
    from selenium.webdriver.common.action_chains import ActionChains
    elememnt=WebDriverWait(driver, 1).until(ec.presence_of_element_located(("xpath", '//*[@id="id123"]')))
    ActionChains(driver).move_to_element(elememnt).click().perform()
    

    OR

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as ec
    from selenium.webdriver.common.action_chains import ActionChains
    elememnt=WebDriverWait(driver, 1).until(ec.presence_of_element_located(("xpath", '//*[@id="id123"]')))
    driver.execute_script("arguments[0].click();",elememnt)
    

提交回复
热议问题