I want to use Python Selenium to automate something.
There is a menu that appears only when we passes the mouse on it without clicking (below "Main Menu") and in the list, we put the mouse on a item (below "Item 2") and a submenu appears. At this moment, we can click on item of the submenu (below "Subitem 2.2"). I want to automate the clicking on Subitem 2.2 for example.
Main menu (mouseover):
- -Item 1
- -Item 2 : -Subitem 2.1
-
-
- -Subitem 2.2
-
Problem, when I click with the right to get the code source, nothing happens and I cannot get the exact ID of the items. So I have to look for it in the code source in Chrome (CTRL + U).
Below is the part of code source that interests me:
<<div id="type1_1n0Items" class="type1_1_0 type1_1_8">
<table border="0" cellpadding="0" cellspacing="0">
<tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(event)" id="type1_1n1">
<td><table class="type1_1_7" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="white-space:nowrap;width:100%;"><a class="type1_1_1 type1_1_6" href="javascript:__doPostBack(XXXXXX;\\Item1')"><img src="../image/cog_edit.png" alt="" style="border-style:none;vertical-align:middle;" />Item 1</a></td>
</tr>
</table></td>
</tr><tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(event)" id="type1_1n2">
<td><table class="type1_1_7" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="white-space:nowrap;width:100%;"><a class="type1_1_1 type1_1_6" href="javascript:__doPostBack(XXXXXX;\\Item2')"><img src="../image/bullet_wrench.png" alt="" style="border-style:none;vertical-align:middle;" />Item 2</a></td>
</tr>
My Python code:
time.sleep(5)
element_to_hover_over=browser.find_element_by_id("type1_1n0Items")
hover = ActionChains(browser).move_to_element(element_to_hover_over)
hover.perform()
Error I get:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="type1_1n0Items"]"}
(Session info: chrome=89.0.4389.114)
Thanks for your help !