Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98819

Try to click button type="button" with selenium using python

$
0
0

I want to click on the button in https://www.airbnb.com/rooms/13921817?location=Seoul%2C%20South%20Korea&previous_page_section_name=1000. I tried several codes, but it failed.

HTML Code:

<li data-id="page-2" class="_1eqazlr">
 <button type="button" class="_1ip5u88" aria-label="Page 2" aria-busy="false">
  <div class="_1bdke5s">2</div>
 </button></li>

Here is the code I have tried:

add="https://www.airbnb.com/rooms/13921817?location=Seoul%2C%20South%20Korea&amp;previous_page_section_name=1000"

driver = webdriver.Chrome(executable_path="C:\Drivers\chromedriver_win32\chromedriver.exe")

driver.get(add)

path="//*[@id='reviews']/div/div/div/section/div[2]/div[3]/div/div/div/nav/span/div/ul/li[2]//button"

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,path))).click()

In addition to "path" above, I tried several different XPATH as follows:

path="//button[contains(@class,\"_lip5u88\") and contains(@aria-label,\"Page 2\")]"

path="//*[@id='reviews']/div/div/div/section/div[2]/div[3]/div/div/div/nav/span/div/ul/li[2]//button"

path="//button[@type='button']//following::div[text()='2']"

path='.//button[[@type="button" and normalize-space()="2"]'

Got errors like these:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button type="button" class="_1ip5u88" aria-label="Page 2" aria-busy="false">...</button> is not clickable at point (214, 871). Other element would receive the click: <div class="_10ejfg4u">...</div>
  (Session info: chrome=77.0.3865.90)

or 

selenium.common.exceptions.TimeoutException: Message: 

Could you help me out to figure it out? Thank you very much!


Viewing all articles
Browse latest Browse all 98819

Trending Articles