Faced such a problem. Learning Automation Python (v3.7) + Selenium, wrote an ancient test for authorization according to the standard

def test_authorization_google(app): app.open_mobile_page() app.login_google(username="name@gmail.com", password="password") app.logout() def login_google(self, username, password): wd = self.wd # наТимаю Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡƒ "Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·Π°Ρ†ΠΈΡŽ" wd.find_element_by_css_selector(".login").click() # появилась страница, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ я наТимаю Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡƒ Π²Ρ…ΠΎΠ΄Π° Ρ‡Π΅Ρ€Π΅Π· соц ΡΠ΅Ρ‚ΡŒ wd.find_element_by_css_selector(".google").click() # Ρ‚ΡƒΡ‚ ΠΎΡ‚ΠΊΡ€Ρ‹Π²Π°Π΅Ρ‚ΡŒΡΡ ΠΏΠΎΠΏΠ°ΠΏ ΠΎΠΊΠ½ΠΎ Π³ΡƒΠ³Π» для Π²Π²ΠΎΠ΄Π° Π»ΠΎΠ³ΠΈΠ½, я Π΅Π³ΠΎ Π²Π²ΠΎΠΆΡƒ wd.find_element_by_name("identifier").click() wd.find_element_by_name("identifier").clear() wd.find_element_by_name("identifier").send_keys(username) # наТимаю Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡƒ "Π΄Π°Π»Π΅Π΅" wd.find_element_by_css_selector("/html/body/div[1]/div[1]/div[2]/div[2]/div/div/div[2]/div/div[2]/div[1]/div/content/span").click() # ΠΎΡ‚ΠΊΡ€Ρ‹Π»ΠΎΡΡŒ ΠΎΠΊΠ½ΠΎ для Π²Π²ΠΎΠ΄Π° пароля, я Π΅Π³ΠΎ Π²Π²ΠΎΠΆΡƒ wd.find_element_by_name("password").click() wd.find_element_by_name("password").clear() wd.find_element_by_name("password").send_keys(password) # наТимаю Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡƒ "Π΄Π°Π»Π΅Π΅" wd.find_element_by_css_selector("/html/body/div[1]/div[1]/div[2]/div[2]/div/div/div[2]/div/div[2]/div[1]/div/content/span").click() 

When I launch it, an additional pop-up window opens for entering the login, and that’s all, the login isn’t entered and after a while the test drops, can anyone tell me how to write the test correctly?

Suppose both when logging in via Google mail at https://automated-testing.info enter image description here

  • Check that wd.find_element_by_name("identifier") finds something. Maybe you need to wait until the page is loaded, here are the expectations of the elements: ru.stackoverflow.com/a/836240/201445 - gil9red
  • Yes, the fact of the matter is that it does not find, a new pop-up window opens there, roughly speaking, one page overlaps another page, but I don’t know how to go and find the element ( - Andrei Petrov
  • new window? <iframe> what? - gil9red 1:08 pm
  • I added a picture in the description of the problem - Andrei Petrov
  • It did not become clearer. Poke the right button on the window with Π’ΠΎΠΉΡ‚ΠΈ and select the item inspection and see what it is. I think that this is an iframe , then you need the code on the example: driver.switch_to.frame(driver.find_element_by_css_selector(css_selector)) - gil9red 1:16 pm

1 answer 1

The driver.switch_to.frame method helped the driver.switch_to.frame :

 driver.switch_to.window(driver.window_handles[1]))