Answer the question
In order to leave comments, you need to log in
Why is it throwing NoSuchElementException?
Hello, I need to parse data from the site, I start the driver, I do everything within 30 seconds (enter hash, specify the number of rounds, wait until everything loads), in the end everything looks like this (prnt.sc/wft0xn).
Everything seems to be fine, but it throws NoSuchElementException, although everything is correctly indicated, I tried to wait through an explicit wait until the page loads at least 1 element, but he also did not see it, although everything was already on the screen and threw an error, I tried it in 2 different ways specify xpath path, but also NoSuch.
from selenium import webdriver
from selenium.common.exceptions import StaleElementReferenceException, NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
import csv
driver = webdriver.Chrome()
driver.get("https://jsfiddle.net/Dexon95/2fmuxLza/show")
sleep(30)
# 53b25a504ddd78121e6473bfc870d3390f32292e35c0bf7a638ef16d8304e45e
a = 1
while True:
# element = WebDriverWait(driver, 40).until(EC.presence_of_element_located((By.XPATH, "/html/body/section/div[3]/table/tbody/tr[1]/td[1]"))) # ждет загрузки страницы
try:
Hash = driver.find_element_by_xpath(f'//*[@id="game_verify_table"]/tr[{a}]/td[1]').text
print(Hash)
Hash = driver.find_element_by_xpath(f'/html/body/section/div[3]/table/tbody/tr[{a}]/td[1]').text
print(Hash)
game = driver.find_element_by_xpath(f'//*[@id="game_verify_table"]/tr[{a}]/td[2]').text
print(game)
game = driver.find_element_by_xpath(f'/html/body/section/div[3]/table/tbody/tr[{a}]/td[2]').text
print(game)
t = [str(a), 'game', '{};'.format(game), '{}'.format(Hash)]
print(t)
a += 1
except StaleElementReferenceException:
print('исключение1')
except NoSuchElementException:
print('исключение2')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question