Home > database >  How to open network login page using selenium firefox webdriver in Python?
How to open network login page using selenium firefox webdriver in Python?

Time:06-01

When I open Firefox on public wifi or any wifi with a login page, I get a button at the top of the browser window, forwarding to the wifi login page. How do I forward to that page using selenium webdriver? I simply want to display that page. EDIT: I have tried

buttons = driver.find_elements(by=By.XPATH, value='//button[normalize-space()="Open network login page"]')

and

buttons = driver.find_elements(by=By.LINK_TEXT, value="Open network login page")

but none of these seem to work.

CodePudding user response:

I have found a simple solution. Firefox provides a captive portal and theres an url to go to, when you want to force the network login page to open. So final code looks like:

driver = webdriver.Firefox()
driver.get("http://detectportal.firefox.com/canonical.html")
driver.implicitly_wait(0.5)
driver.fullscreen_window()

This results in Firefox showing the network login page.

  • Related