In selenium how to access warnings window for information not found?

30 views
Skip to first unread message

Reinaldo Chaves

unread,
Jun 11, 2018, 10:29:52 PM6/11/18
to Selenium Users

In python 3 and selenium webdriver I have this program to enter codes in a website and store the information returned:


from selenium import webdriver

profile = webdriver.FirefoxProfile()
browser = webdriver.Firefox(profile)

# Site that is accessed
browser.get('https://www.fazenda.sp.gov.br/SigeoLei131/Paginas/ConsultaDespesaAno.aspx?orgao=')

# Select year 2018
browser.find_element_by_xpath('/html/body/form/div[3]/table/tbody/tr[2]/td/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]/select/option[1]').click()

# Enter the code 07022473000139
browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_rblDoc_0"]').click()
browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_txtCPF"]').send_keys('07022473000139')
browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_btnPesquisar"]').click()

# Stores the information found
company = browser.find_element_by_xpath('/html/body/form/div[3]/table/tbody/tr[2]/td/table/tbody/tr[3]/td/div/table/tbody/tr[2]/td[1]').text
value = browser.find_element_by_xpath('/html/body/form/div[3]/table/tbody/tr[2]/td/table/tbody/tr[3]/td/div/table/tbody/tr[2]/td[2]').text

# Go back one screen to do another search
browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_btnVoltar"]').click()

I have a list of codes to search the site in the field: "CNPJ/CPF/Inscrição genérica/UGE favorecida :"


In this list I have already discovered that some codes do not exist in the site database (I do not know how many do not exist). And when I type a code that does not exist (like '07022473000136') a window opens on the site with the message "Não existe Credor com o filtro informado" and I can only continue by pressing the OK button


I did not find this warning message in the site code, so I still do not know how to handle it


Please, would anyone know how to test whether or not the code exists in selenium? And if not, how do I press the OK button to continue?


Ahmet Melik Öztürk

unread,
Jun 20, 2018, 4:37:13 AM6/20/18
to Selenium Users
This might be useful : https://stackoverflow.com/questions/47342857/how-can-i-click-on-a-popup-window-in-selenium-java

I am not sure though.

12 Haziran 2018 Salı 05:29:52 UTC+3 tarihinde Reinaldo Chaves yazdı:
Reply all
Reply to author
Forward
0 new messages