I'm working on simple automation in Selenium. I need to click a specific button. I can't because it is hidden in div/table without class.
I'm attaching a screenshot of the html. I did try xpath, css select, select and still nothing.
I'm working on simple automation in Selenium. I need to click a specific button. I can't because it is hidden in div/table without class.
I'm attaching a screenshot of the html. I did try xpath, css select, select and still nothing.
You could try clicking the div then. You can use XPath to locate the button element (as it has some class so you can locate it) and add
/parent::div
to get the div to click it.
To click()
on the button you have to induce WebDriverWait for the desired visibility_of_element_located()
and you can use either of the following Locator Strategies:
Using CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "ul.nightclubs.unstyled > li > table.table.table-condensed button.btn.btn-inverse.btn-small.pull-right"))).click()
Using XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//ul[@class='nightclubs unstyled']/li/table[@class='table table-condensed']//button[@class='btn btn-inverse btn-small pull-right' and contains(., 'Wejd')]"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC