c# - Selecting a menu item after hovering over a parent menu item using selenium -
i want select "application processing" menu item after hover on "asmt admin" parent menu item option. html follows:
<div id="topmenu"> <div id="ctl00_topmenu1" class="radmenu radmenu_governblue rmsized"> <ul class="rmrootgroup rmshadows rmhorizontal"> <li class="rmitem"> <a class="rmlink rmrootlink" href="#"> <span class="rmtext rmexpanddown">asmt admin</span> </a> <div class="rmslide"> <ul class="rmvertical rmgroup rmlevel1"> <li class="rmitem "> <a class="rmlink" href="#"> <span class="rmtext">application processing</span> </a> </li> </ul> </div> </li> </ul> </div> </div>
i tried follows:
from selenium import webdriver selenium.webdriver.common.by import selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec selenium.webdriver.common.action_chains import actionchains browser = webdriver.chrome() browser.get(('localhost:81')) wait = webdriverwait(browser, 10) asmtadmin = wait.until(ec.visibility_of_element_located((by.xpath, "//a/span[text()='asmt admin']"))) actionchains(browser).move_to_element(asmtadmin).perform() applicationprocessing = wait.until(ec.visibility_of_element_located((by.xpath, "//a/span[text()='application processing']"))) actionchains(browser).move_to_element(applicationprocessing).click().perform()
but "application processing" menu item not clicked neither command line show errors.
what doing wrong? please help.
your code looks pretty me suggest 2 changes follows:
- as doing
browser.get(('localhost:81'))
, next doing(by.xpath, "//a/span[text()='asmt admin']")
think can omit referencewebdriverwait
. - when searching element
(by.xpath, "//a/span[text()='application processing']")
instead ofec.visibility_of_element_located
can useec.element_to_be_clickable
your final code like:
asmtadmin = driver.find_element_by_xpath("//a/span[text()='asmt admin']") actions = actionchains(browser) actions.move_to_element(asmtadmin).perform() applicationprocessing = webdriverwait(driver, 20).until( ec.element_to_be_clickable((by.xpath, "//a/span[text()='application processing']")) ) applicationprocessing.click()
Comments
Post a Comment