Automation with Selenium Webdriver Python

Asked

Viewed 55 times

0

I’m doing an automation. where I access one page to be able to go to another, after going to another page I try to click on an element, but even using Webdriverwait is showing that it was not found at the given time.

The code in question:

import time
import requests
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import StaleElementReferenceException
from bs4 import BeautifulSoup

driver = webdriver.Chrome(executable_path=r'./chromedriver.exe')


## Endereço do site da coleta
url = "https://gool.cittati.com.br/Login.aspx?ReturnUrl=%2f"

driver.get(url)
#time.sleep(10)

## Logar 
login = driver.find_element_by_xpath("//div[@class='listaIcones']//ul//li//input[@id='ucTrocarModulo_btnIconeUrbano']")
login.click()

txt_username_locator = (By.ID, "ucLogarUsuario_txtLogin")       # colocando usuario
element_username = WebDriverWait(driver, 20).until(EC.element_to_be_clickable(txt_username_locator)) 
element_username.send_keys("###")

txt_passwoard_locator = (By.ID, "ucLogarUsuario_txtSenha")      # colocando senha
element_password = WebDriverWait(driver, 20).until(EC.element_to_be_clickable(txt_passwoard_locator))
element_password.send_keys("###")
element_password.send_keys(Keys.ENTER)

## Acessar o sinótico
driver.execute_script("window.open('https://gool.cittati.com.br/goolsystem/sinotico/PrincipalSinotico.aspx')")
sinotico = driver.window_handles[1]
driver.switch_to.window(sinotico)
entrar = driver.get("https://gool.cittati.com.br/goolsystem/sinotico/PrincipalSinotico.aspx")

## filtar e pesquisar:
search = (By.CLASS_NAME, "bordaEsquerda")
element_search = WebDriverWait(driver, 20).until(EC.element_to_be_clickable(search))
element_search.click()

Why can’t find the element search ? It is still searching on the first page and not on the second, called as synoptic ? How can I know what page the element is being searched for ?

No answers

Browser other questions tagged

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