Reputation: 155
So I wrote a python script that uses Selenium 2 to do various things to my modem. This fully works.
I am now busy updating the script to use Selenium 3, but I immediately ran into a problem where I cannot even get to the login page of the modem. The problem seems to be with the get()
.
First of all it now crashes when given a fake URL. I then gave it the Google URL and it works perfectly, but now I need to go to the modem's IP. But when I use driver.get(_rout_ip)
, where _rout_ip
is 10.0.0.2, it just appends the IP address to the Google URL. Removing the get
for the fake URL is not an option since for some reason it is required as it cannot directly go to the modem ip.
The code for getting the webdriver instance is below
def get_driver():
"""
Get an instance of a webdriver that is initialized to the router login page
:return: A webdriver instance
"""
if not os.path.exists(os.getcwd() + '\\' + _driver_name):
print('ERROR: The specified driver does not exist, %s' % (os.getcwd() + '\\' + _driver_name))
exit()
print "Initializing the webdriver"
# Set the path to the driver to be used
os.environ["webdriver.gecko.driver"] = os.getcwd() + '\\' + _driver_name
driver = webdriver.Firefox()
# Go to a fake website. This is needed since it cannot go to the modem directly for some reason
try:
driver.get('http://poop_smells_nice.com')
except Exception:
print('WOOT')
waiter.sleep(_SLEEP_TIME) # Pause a bit to be safe
print "Switching to the router login page"
# Go to the modem ip
driver.get(_rout_ip)
driver.switch_to.default_content()
return driver
Does anyone have any idea why this is happening?
Upvotes: 2
Views: 4551
Reputation: 184081
10.0.0.2
is not a URL and so the browser falls back on searching for it. Try http://10.0.0.2/
Upvotes: 3