Answer the question
In order to leave comments, you need to log in
What is the correct xpath for the popup element?
Hello.
I'm trying to implement an algorithm that will click on a button that appears in a popup menu.
I.e. There is an element of the page, when you hover the mouse on which a menu pops up. And in this menu you need to press the button.
The code is next.
d.implicitly_wait(10)
menu = d.find_element_by_css_selector('a.n-t.bold')
actions = ActionChains(d)
actions.move_to_element(menu)
hidden_submenu = d.find_element_by_xpath('//span[contains(text(),"Отписаться")]')
actions.click(hidden_submenu)
actions.perform()
Answer the question
In order to leave comments, you need to log in
actions.move_to_element(menu).perform()
d.find_element_by_xpath('//span[contains(text(),"Отписаться")]').click()
1. actions.perform() must be raised higher, because when searching for hidden_submenu , the mouse cursor has not yet hovered over menu .
2. Also, most likely, when you hover the mouse over menu , hidden_submenu appears with a delay and you need to look towards waiting https://selenium-python.readthedocs.io/waits.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question