Click on pseudo element using Selenium

前端 未结 4 1077
清歌不尽
清歌不尽 2020-12-31 08:53

I am trying to use Selenium to click on a ::after pseudo element. I realize that this cannot be done through the WebDriver directly, but cannot seem to figure out a way to d

4条回答
  •  有刺的猬
    2020-12-31 09:39

    For those who are trying to do this in Python, the solution is below:

    elem= driver. ActionChains(driver).move_to_element_with_offset(elem,249,1).click().perform()

    Basically here I'm finding my element in the DOM and assigning to a WebElement. The WebElement is then passed the method move_to_element_with_offset as a param.

    I got the px values for the element from developer tools.

    PS: use this import- from selenium.webdriver.common.action_chains import ActionChains

    You can read more about Action chain class and its method move_to_element_with_offset here: http://selenium-python.readthedocs.io/api.html.

    Hope this helps.

提交回复
热议问题