I am attempting to find a robust xpath to click a button in the screenshot below
I want to click on the "eStatus" button
The HTML of the element is made up on the following
I have attempted to locate the button using the following xpath but it is not working.
login_Check=driver.find_element(By.XPATH,'/html/body/div/div/div[1]/ul/table/tbody/tr/td[2]/li/strong/em').click()
Please help me with this.
Use below code to locate the element using xpath:
driver.find_element(By.XPATH, "//li[@id='mn1'][strong/em[text()='eStatus']]")
Since, the button is inside frame element, use below code to switch to the frame before accessing the button using above xpath:
frame_element = driver.find_element_by_name("IDXHeader")
driver.switch_to.frame(frame_element)
Once you're done accessing element inside frame, make sure you siwtch back to default content using below code:
driver.switch_to.default_content()
So, your code should be as below:
frame_element = driver.find_element(By.NAME, "IDXHeader")
driver.switch_to.frame(frame_element)
driver.find_element(By.XPATH, "//li[@id='mn1'][strong/em[text()='eStatus']]").click()
driver.switch_to.default_content()
You could also use below code to locate button:
driver.find_element(By.XPATH, "//li[strong/em[text()='eStatus']]")