Python + Selenium + find_element

Asked

Viewed 10 times

0

Good afternoon, I’m starting in Python and I’m making a web scraping robot for a site where I am obliged to inform user and password.

I am using the Selenium and the part to inform user and password ok, below the code already produced

gecko = "C:\Temp\Projetos\SCRAPER\src\scraper\geckodriver.exe"
binary = FirefoxBinary(r"C:\Program Files\Mozilla Firefox\firefox.exe")
browser = webdriver.Firefox(firefox_binary=binary, executable_path=gecko)

# Variaveis para processamento
url = "https://xxxxxx.xxxxxxx.com.br/sbe-web/login/login.html?modulo=PESSOA_JURIDICA"
usr = "123456"
pwd = "123456"

# Abre o browser
browser.get(url)
browser.implicitly_wait(10)

usuario = browser.find_element_by_name("nomeUsuario")
usuario.clear()
usuario.send_keys(usr)

senha = browser.find_element_by_name("senha")
senha.clear()
senha.send_keys(pwd)

elem = browser.find_element(with_tag_name("input").below(senha)).click

However I came across a case where the element I need to click is an image that has no tag/name, I tried to get xpath but it brings a giant html, I entered the Selenium documentation and tried to use Bellow() command, because I understood that it looks for the next element, but without success

elem = browser.find_element(with_tag_name("input").Below(password)). click

<td rowspan="2" valign="center">
    <input type="image" src="/sbe-web/especifico/imagens/ok.jpg" tabindex="3">
</td>

Can you help me.

No answers

Browser other questions tagged

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