Gozu09
Gozu09

Reputation: 43

Selenium web driver Firefox opening blank page

I'd like to ask something about Selenium library in Python.

I'm trying to open a webpage, directly log onto it, and access another webpage behind it (I wanted to navigate on the website after the login) with a Python script. I've found the following code on the Internet but I have a problem with the line:

browser = webdriver.Firefox()

It just opens a blank page in Firefox and it looks like the script get stuck with it and does nothing afterwards. I tried in the Python interpreter and it's the same, it opens a blank page in Firefox and I lose the hand (I can't enter other commands).

python interpreter blocked:

I'm using Selenium-3.3.1 and I work under CentOS 6.5.

Is it normal? Am I missing something obvious?

Here is my code:

#!usr/bash/python

from selenium import webdriver
from selenium.webdriver.support import ui
from selenium.webdriver.common.keys import Keys

def loadedPage(browser):
    return browser.find_element_by_tag_name("body") != None

browser = webdriver.Firefox() #supposedly just a firefox webdrive instance creation

browser.get("http://machine/machineDir/index.php")
wait = ui.WebDriverWait(browser, 10)
wait.until(loadedPage)

username=browser.find_element_by_id("username")
username.send_keys("userTest")

passwd=browser.find_element_by_id("password")
passwd.send_keys("userTestpass")
passwd.send_keys(Keys.RETURN)

Upvotes: 2

Views: 4914

Answers (2)

Gozu09
Gozu09

Reputation: 43

I fixed it using the right version of Selenium for my old Firefox.

  • Firefox version: 17.0.10
  • Selenium version installed: 2.40

Upvotes: 0

Veena Devi
Veena Devi

Reputation: 40

As you are using selenium 3, firefox browser can't be instantiate directly, you need to configure gecko driver for the same.

System.setProperty("webdriver.gecko.driver","path of geckodriver.exe");

Upvotes: 1

Related Questions