S
S
SHADRIN2019-02-27 14:21:29
Python
SHADRIN, 2019-02-27 14:21:29

Python selenium, page error what to do?

There is a code ...
His task on the site is to find a match (finds)
Click on the match and go to all the information (does)
Update page data (can)
Go back (can)
That's the question when he came back he doesn't understand where he is, like I would just get (url) but it is in a cycle and xs how to be, help me out

for block in driver.find_elements_by_xpath('//div[@class="line-event"]'):
        	result = re.search(r'basketball', str(block.get_attribute('outerHTML')))
        	if result: # event last что то придумать
        		inblock = block.find_element_by_css_selector('a.line-event__name-link').click()
        		urls = driver.current_url
        		driver.get(urls)
        		#----------------#




        		#----------------#
        		back = driver.find_element_by_xpath('/html/body/app-root/main/div/app-live-bets/app-scoreboard/div/div/div[1]/a[1]')
        		time.sleep(3)
        		back.click()

Traceback (most recent call last):
  File "D:\repos\myscore\mysc.py", line 407, in <module>
    name_main()
  File "D:\repos\myscore\mysc.py", line 25, in name_main
    main(login, password)
  File "D:\repos\myscore\mysc.py", line 42, in main
    result = re.search(r'basketball', str(block.get_attribute('outerHTML')))
  File "C:\Users\saxar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 141, in get_attribute
    self, name)
  File "C:\Users\saxar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "C:\Users\saxar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\saxar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of <div class="line-event"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question