简体   繁体   中英

Click on “Show more deals” in webpage with Python Selenium

I'm using the following code to click on the 'Show more reviews' button, but not working.

Code:

link= 'https://www.capterra.com/p/5938/Oracle-Database/'
driver.get(link)
while True:
    try:
        driver.find_element_by_partial_link_text('Show more reviews').click()
        # Wait till the container of the recipes gets loaded 
        # after load more is clicked.
        time.sleep(5)
    except (NoSuchElementException, WebDriverException) as e:
        break

page_source = driver.page_source

#BEAUTIFUL SOUP OPTION
soup = BeautifulSoup(page_source,"lxml")

Error Statement

NoSuchElementException: no such element: Unable to locate element: {"method":"partial link text","selector":"Show more reviews"}
(Session info: headless chrome=76.0.3809.132)

Thanks in advance.

Found an answer to it.

driver.find_element_by_xpath('//button[normalize-space()="Show more reviews"]').click()

Reference - https://stackoverflow.com/a/48673343/6486100 Thanks @Andersson

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM