0

A relatively simple issue, I am trying to click on the "Car" button on this site, using Selenium to do this, I have the following code

    from selenium import webdriver
from webdriver_manager.chrome import  ChromeDriverManager

def runScript():
    with open("plates.txt") as file:
        lines = [line.rstrip() for line in file]

    browser = webdriver.Chrome(ChromeDriverManager().install())
    browser.get('https://www.myplates.com.au/#/')
    browser.find_element_by_class_name('col-3 col-md-3 rfh-item-box ng-star-inserted').click();


if __name__ == '__main__':
    runScript()

Now I wish to click on this button here

This is located on this site

This is the button I wish to click

https://www.myplates.com.au/#/

I also need to select the text drop box and write some input into it how would I also go about doing this.

Thank you any assistance is appreciated

1 Answers1

0

The desired element is a Angular element, so to click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategies:

  • Using XPATH:

    driver.get('https://www.myplates.com.au/#/')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='row rfh-menu-list']//div[@class='row']//div[contains(@class, 'rfh-type-item') and contains(., 'Car')]"))).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
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352