Search code examples
pythonlinuxseleniumselenium-webdrivergeckodriver

Browser.get() method can't get the URL. This code is a part of a Python code


OS:- Kali linux 2019.1 Firefox 60.6.1 Geckodriver :- 0.18.0 selenium 3.5.2

The code gets stuck after the browser.get line. When I check the geckodriver logs..it shows > ddons.productaddons WARN Failed downloading via XHR, status: 0, reason: error (Don't Know if it is relevant)

I tried changing the " to ' for the URL, Tried changing browser.get to browser.navigate.to with no success. The URL works fine. I can open it in firefox browser. It also doesn't take a lot of time to open. So, doesn't seem to be a wait() issue.

# ------------[STARTS A WEBSERVER + FORWARDS PORT WITH NGROK]------------- #

os.system('xterm -e "cd ./WEBSERVER/ && php -S 127.0.0.1:80" &')
os.system("./ngrok http 80 > /dev/null &")




time.sleep(3)
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox(firefox_binary=binary,executable_path='base/geckodriver')
browser.get("http://localhost:4040/status")
time.sleep(5)
url_f=str(browser.find_element_by_css_selector("li.list-unstyled:nth-child(1) > div:nth-child(2) > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2)").text)
browser.close()
show_url = str(url_f)


# `GENERATES EMAIL TEMPLATE


emaildata = str(EMAIL1_TW)
emaildata = emaildata.replace('_EF', str(UNAME))
emaildata = emaildata.replace('G_URL', str(n_url))
emaildata = emaildata.replace('Windows 7', str(Email_OS))
emaildata = emaildata.replace('Antartica', str(Email_from))


# `DECIDES THE EMAIL ADDRESS

from_email = str(random.choice(['[email protected]','[email protected]']))



##################################
#      SENDS  EMAIL       #
##################################


subprocess.call(['sendemail', '-f', from_email,'-t', str(Email), '-u', 'Notice for you', '-m', emaildata, '-s', smtps+":"+port, '-o', 'tls=no','-xu', username, '-xp', password])
os.system('reset')

Solution

  • The error trace logs would have helped us to debug the issue in a better way. However your main issue is the incompatibility between the version of the binaries which you are using:

    • Firefox v60.6.1
    • Geckodriver v0.18.0
    • Selenium v3.5.2

    If you are using GeckoDriver-Selenium-Firefox combo, you need to follow the following compatibility chart:

    supported_platforms_geckodriver_24

    You can find a detailed discussion in Which Firefox browser versions supported for given Geckodriver version?