0
    for i in href2[420:423]:
        driver.get(i)
        time.sleep(3)
        #scroll down
        actions = ActionChains(driver)
        for _ in range(4):
            actions.send_keys(Keys.PAGE_DOWN).perform()
            time.sleep(2)
        #click on view more    
        time.sleep(2)
        try:
            view_all = driver.find_element_by_xpath("//*[@id='specification-wdght']/div/div/div/div")
            driver.execute_script("arguments[0].click();", view_all)
        except NoSuchElementException:
            view_more = driver.find_element_by_xpath("//*[@id='topspec']/div[2]/a")
            driver.execute_script("arguments[0].click();",view_more) 
        else:
            pass
        
        time.sleep(10)

Error:

    NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='topspec']/div[2]/a"}

Here I am trying to scrape car detail but on page 420 neither view_all option is there nor view_more and the script is throwing the error of no such element.

So how I am gonna handle this? I am confused please help me out with this.

1
  • Do you mean that the elements you are trying to locate and click are not available in the page? Dec 1 '21 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.