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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Reinaldo Chaves

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?


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/641de1ed-cefe-42a2-9f90-bd3249c68902%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Ahmet Melik Öztürk
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ı:

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('<a href="https://www.fazenda.sp.gov.br/SigeoLei131/Paginas/ConsultaDespesaAno.aspx?orgao=" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.fazenda.sp.gov.br%2FSigeoLei131%2FPaginas%2FConsultaDespesaAno.aspx%3Forgao%3D\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFA3fyna3ymb64h4uKcsaLCnfxYvQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.fazenda.sp.gov.br%2FSigeoLei131%2FPaginas%2FConsultaDespesaAno.aspx%3Forgao%3D\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFA3fyna3ymb64h4uKcsaLCnfxYvQ&#39;;return true;">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?


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/bfce0e96-8f3b-4374-810c-4a641017f1a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.