1

Below code gives few of values it's not displaying all values in the page.

from selenium import webdriver
chrome_path = r"C:\Users\Venkatesh\AppData\Local\Programs\Python\Python35\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.get("https://www.flipkart.com/mobiles")
search = driver.find_element_by_xpath("""//*[@id="container"]/div/div[2]/div/div[3]/div[1]/div/div[4]/div[1]/div/div/a""").click()
timeout = 20
posts = driver.find_elements_by_class_name("iUmrbN")
for post in posts:
    print(post.text)

I am getting output like below and error also showing how to solve these problem

  Sony Xperia XZs
    Moto g5 Plus
    Swipe Elite Sense
    OPPO F3 Plus (Gold, 64 GB)








    SAMSUNG On Nxt
    Swipe Elite Max (Onyx Black, 32 GB)
    Lenovo K5 Note (4GB)
    Zenfone 3 Laser




    Traceback (most recent call last):
      File ".\ff1.py", line 9, in <module>
        print(post.text)
      File "C:\Users\Venkatesh\AppData\Local\Programs\Python\Python35\Lib\site-packages\selenium\webdriver\remote\webelement
    .py", line 73, in text
        return self._execute(Command.GET_ELEMENT_TEXT)['value']
      File "C:\Users\Venkatesh\AppData\Local\Programs\Python\Python35\Lib\site-packages\selenium\webdriver\remote\webelement
    .py", line 491, in _execute
        return self._parent.execute(command, params)
      File "C:\Users\Venkatesh\AppData\Local\Programs\Python\Python35\Lib\site-packages\selenium\webdriver\remote\webdriver.
    py", line 238, in execute
        self.error_handler.check_response(response)
      File "C:\Users\Venkatesh\AppData\Local\Programs\Python\Python35\Lib\site-packages\selenium\webdriver\remote\errorhandl
    er.py", line 193, in check_response
        raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to
    the page document
      (Session info: chrome=57.0.2987.133)
      (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT

6.2.9200 x86_64)

0

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.