I'd like to click on every 'Show 10 more deals' on the following page: "https://www.uswitch.com/broadband/compare/deals_and_offers/" but it does not seem to work. I'm stuck having the following error:
AttributeError: 'NoneType' object has no attribute 'find_element'
My code is the following:
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
url = "https://www.uswitch.com/broadband/compare/deals_and_offers/"
driver = webdriver.Chrome(r'C:\temp\chromedriver.exe')
browser = driver.get(url)
while True:
button = WebDriverWait(browser,10).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, 'Show 10 more deals')))
button.click()
Any idea?
Try the following which uses a CSS attribute = value selector to target the
data-event-action
attribute of the button by its valueReplace
driver
withbrowser
if required.Try it like this:
This avoids the selenium errors that will eventually drive you nuts.
To click on the element with text as Show 10 more deals on the page
https://www.uswitch.com/broadband/compare/deals_and_offers/
you can use the following solution:Code Block:
Console Output: