I cannot click on the alert using Selenium

Asked

Viewed 123 times

-1

When clicking a button, an alert is issued asking me to confirm, it turns out that I already tried using Pynput to confirm with ENTER Key.press. But it didn’t work. The alert is in another window, so Lenium doesn’t see it

inserir a descrição da imagem aqui

When inspecting the button, there is a HREF code with another link, which I cannot directly click on. So the solution would be to pass with a ENTER, but I could not with PYNPUT, any idea? My code below

browser = Chrome()

wdw = WebDriverWait(browser,10)
browser.get('https://sso.acesso.gov.br/login?client_id=cav.receita.fazenda.gov.br')

browser.implicitly_wait(15)
browser.find_element_by_xpath('//*[@id="login-dados-certificado"]/p[2]/a/img').click()
browser.find_element_by_xpath('//*[@id="cert-digital"]/a').click()

wdw.until(
    new_window_is_opened(browser.window_handles)
)

browser.switch_to_window(
    browser.window_handles[-1]
)

browser.switch_to_alert

1 answer

0

just use the pyautogui library little brother, example type makes it move the mouse and click the warning.

inserir a descrição da imagem aqui

  • Welcome to Stack Overflow! You have placed an image of the code. Although it seems like a good idea, it is not! One of the reasons is that for the author of the question to test it cannot copy the code and change something inside. Click the edit link and put the code/error as text.

Browser other questions tagged

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