1

Here is the website which I'm trying to automate for scraping data: website link. I have to do the following:

  1. select Location as Victoria, then region as Melbourne.
  2. select Make as, say, Abarth. the will repeat for other makes.

I have tried static xpaths and also tried creating dynamic xpaths with my limited knowledge but still i am not able to do the task.

I use python selenium and automating google chrome.

Here is a snapshot of my wrong code for selection Abarth as make:

make_ele = WebDriverWait(driver,40).until(EC.element_to_be_clickable((By.XPATH, '//*[@data-name="make"]'))).click()
select_abarth_ele = WebDriverWait(driver,40).until(EC.element_to_be_clickable((By.XPATH, '//div[@class="multiselect-searchbox"]//input[@class, "border py-1 px-2 mb-1")]'))).send_keys("Abarth")
Harsh Vardhan
  • 113
  • 1
  • 2
  • 11

1 Answers1

0

Your xpaths has to be reviewed. Try this:

make_ele = WebDriverWait(driver,40).until(EC.element_to_be_clickable((By.XPATH, '//span[contains(text(),'Make')]'))).click()
select_abarth_ele = WebDriverWait(driver,40).until(EC.element_to_be_clickable((By.XPATH, '//div[contains(@class,"multiselect-searchbox")]/input'))).send_keys("Abarth")

If you don't want to use contains(text(),'text') you can use also following relative path //div[@data-name="make"]

WKOW
  • 346
  • 2
  • 9
  • after writing Abarth in the filter box, i am trying to select it.... so im writing this xpath.. select_make_ele = WebDriverWait(driver,40).until(EC.element_to_be_clickable((By.XPATH, '//li[contains(@class,"multiselect-facets-item border-bottom"]/span[@class="icon-tick"]'))).click() but it doesnt seem to work. – Harsh Vardhan Dec 08 '20 at 11:55
  • Maybe try to use this --> //label[text()="Abarth"] And that click on search button --> //a[text()="Search"] – WKOW Dec 08 '20 at 12:05