8

I have been trying for a while to figure out how to enter username and password in the popup-window in this exercise:

http://pentesteracademylab.appspot.com//lab/webapp/digest

but I am entirely new to Selenium in Python. I found out how to click the button, so that the login form pops up:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://pentesteracademylab.appspot.com//lab/webapp/digest")
driver.find_element_by_css_selector('button').click()

but I cannot figure out how to access that window, let alone the fields in it. I have read about switch_to_frame and switch_to_window. For windows there is the window_handles showing you active windows to switch to, but this only returns a single element, which I believe is the main window, not the pop up. I also tried

alert = driver.switch_to_alert()

to no avail. The problem is that I do not know either which kind of object the popup is (frame,window,alert or something else), and I cannot find any names referring to it in the HTML code for the webpage.

Can anyone take me a step further?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
String
  • 207
  • 1
  • 2
  • 8

1 Answers1

11

Pass the authentication step by accessing the following URL:

http://username:password@pentesteracademylab.appspot.com/lab/webapp/digest/1

See also:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Ah, OK! Thank you! That changes the whole approach entirely. Does that mean that I cannot access the popup? Is the popup somehow not visible to Selenium by any standard approaches? – String Apr 08 '15 at 14:07
  • @String yeah, this kind of popup cannot be accessed via `selenium`. The provided solution helps to avoid the popup being shown in the first place. – alecxe Apr 08 '15 at 14:08
  • Great! Yes, I inferred that from the URL :) – String Apr 08 '15 at 14:09
  • Any idea why this doesn't work on Chrome/Windows? The same url works on OSX. – gplayer Jun 28 '16 at 07:35
  • @gplayer interesting, not sure, could you please elaborate it into a separate question including all the necessary details? Thanks. – alecxe Jun 28 '16 at 14:26
  • Wouldn't this send very confidential information like username/password in clear-text - which would be a huge security risk ? – Susheel Javadi Jul 29 '16 at 06:13
  • it does not work for me – Azam Jul 21 '23 at 01:39