Selenium.common.exceptions.Nosuchelementexception: Message: Unable to locate element: //div[@class='classificacao_run points']//table

Asked

Viewed 46 times

2

Hello,

I made a python webscraping on mozzarella and it worked. However, when I tried to apply the code on another site, I’m getting the title error message.

In practice:

  1. When running the program the mozila is opened and you pass 10s of the command time.sleep(10)

  2. Next appears the error in promt for the line:

driver.find_element_by_xpath("//div[@class='classificacao_pontos-corridos']//table//thead//tr//th[@class='tabela_head--coluna']").click
  1. When trying to remove that part of the cochlea the same error goes to the line:
element = driver.find_element_by_xpath("//div[@class='classificacao_pontos-corridos']//table")

code:

import time
import requests
import pandas as pd

from bs4 import BeautifulSoup

from selenium import webdriver

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')

driver = webdriver.Firefox(firefox_binary=binary, executable_path=r'C:\geckodriver-v0.28.0-win64 
(1)\\geckodriver.exe')

url = "https://globoesporte.globo.com/futebol/brasileirao-serie-a/"

driver.get(url)   

time.sleep(10)

driver.find_element_by_xpath("//div[@class='classificacao_pontos- 
corridos']//table//thead//tr//th[@class='tabela_head--coluna']").click

element = driver.find_element_by_xpath("//div[@class='classificacao_pontos-corridos']//table")

html_content = element.get_attribute('outerHTML')
  • Hello Leonardo, maybe the DIV this inside an iframe or the element does not yet exist, try Webdriverwait: https://answall.com/a/425211/3635

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.