0

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.

HTML

DebanjanB
  • 118,661
  • 30
  • 168
  • 217
popo1992
  • 13
  • 1
  • 3
    Post your html in text format.Screenshot doesn't help other contributor to help you.Please post your code as well what you have done. – KunduK Sep 09 '19 at 21:38
  • 3
    See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Sep 10 '19 at 02:52

2 Answers2

0

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.

RegCent
  • 68
  • 10
0

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
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217