1

I'm new in Webscraping, I want to click this button "Afficher plus" which has the HTML code below.

<button class="more-results js-more-results" id="search-more-results">Afficher plus de résultats</button>

 

I tried the code below in selenium but it doesn't click the button.

driver = webdriver.Safari() 
driver.get(carte)
bt = driver.find_element_by_id("search-more-results")
bt.click()

"carte" is the link the of web page I want to scrape.

1
  • Are you getting any error? Commented Jun 10, 2021 at 20:48

1 Answer 1

1

1 Check if this button is not inside an iframe.

2 If not, try waiting until this button is clickable

3 '"carte" is the link the of web page I wanna to scrape.' You are using get() function incorrectly. It is used to open a page, not to get a link from a page.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Safari() 
driver.get("YOUR WEB PAGE")
wait = WebDriverWait(driver, 30)
wait.until(EC.element_to_be_clickable((By.ID, "search-more-results")))
bt = driver.find_element_by_id("search-more-results")
bt.click()

If this won't work, try CSS selector or XPath. Example for CSS:

wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#search-more-results")))
email = driver.find_element_by_css_selector('#search-more-results').click()
Sign up to request clarification or add additional context in comments.

1 Comment

hi I finale discover that I should add. driver.execute_script("arguments[0].click();", bt) to click the button because it need to excuse a script. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.