SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.58k stars 8.17k forks source link

find_element_by_id throws exception in selenium 3.6.0 for python with FireFox 55+ #4884

Closed isalsberg-mx closed 7 years ago

isalsberg-mx commented 7 years ago

Meta -

OS: OSX 10.12.6

Selenium Version: 3.6.0 for python

Browser: FireFox

Browser Version: 55+ with geckodriver 0.19.0

Expected Behavior -

Find an element by id in the page using browser.find_element_by_id function

It works just fine with Firefox 54-

Actual Behavior -

Throwing exception:

Traceback (most recent call last): File "FUE.py", line 58, in filter_button=browser.find_element_by_id(filter_button_id) File "/Users/.../GeckoDriver/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 341, in find_element_by_id return self.findelement(by=By.ID, value=id) File "/Users/.../GeckoDriver/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 843, in find_element 'value': value})['value'] File "/Users/.../GeckoDriver/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute self.error_handler.check_response(response) File "/Users/.../GeckoDriver/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None Message:

Steps to reproduce -

Open any page with Firefox using selenium webdriver and try to find an element using function browser.find_element_by_id('some_element_id'):

from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

firefox_capabilities = DesiredCapabilities.FIREFOX firefox_capabilities['marionette'] = True

ff_profile = webdriver.FirefoxProfile('my_profile_path') ff_binary = FirefoxBinary('/Applications/Firefox.app/Contents/MacOS/firefox-bin') browser = webdriver.Firefox(firefox_profile=ff_profile, firefox_binary=ff_binary)

browser.get('base_url' + '/some_PAGE') filter_button=browser.find_element_by_id('filter_button_id')

barancev commented 7 years ago

For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.

See CONTRIBUTING.md

isalsberg-mx commented 7 years ago

Hello Alexei, I double checked with other websites and the problem is happening ONLY with  the web site written in the code, which requires login credentials and user certificate to access.

If I use this very same code in any other place, asking for credentials and certificate or not IT WORKS FINE.

The problem is only with this web site (which is the one I need to work with). I tried three different pages and all of them failed with the same problem. I downloaded the source code of the page add it to Apache try the code and works OK :(

This happens with FF 55+ with FF 54- it is working FINE!

Steps to reproduce it: CODE:

from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.firefox.firefox_binary import FirefoxBinary firefox_capabilities = DesiredCapabilities.FIREFOX firefox_capabilities['marionette'] = True ff_profile = webdriver.FirefoxProfile('/Users/isaac/Library/Application Support/Firefox/Profiles/ts7fntas.default') ff_binary = FirefoxBinary('/Applications/Firefox.app/Contents/MacOS/firefox-bin') browser = webdriver.Firefox(firefox_profile=ff_profile,firefox_binary=ff_binary) browser.get('https://www.finratraqs.org/Pages/UnmatchedTradeReportsManagement.aspx?Facility=TRACE&Product=CA&BreadCrumb=0202') ilter_button = browser.find_element_by_id('ctl00_MainContentPlaceHolder_ctl00_FilterButton')  browser.quit()

Python interpreter output: Python 2.7.13 (default, Jan 18 2017, 17:45:38)  [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwinType "help", "copyright", "credits" or "license" for more information.

from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.firefox.firefox_binary import FirefoxBinary firefox_capabilities = DesiredCapabilities.FIREFOX firefox_capabilities['marionette'] = True ff_profile = webdriver.FirefoxProfile('/Users/isaac/Library/Application Support/Firefox/Profiles/ts7fntas.default') ff_binary = FirefoxBinary('/Applications/Firefox.app/Contents/MacOS/firefox-bin') browser = webdriver.Firefox(firefox_profile=ff_profile,firefox_binary=ff_binary) browser.get('https://www.finratraqs.org/Pages/UnmatchedTradeReportsManagement.aspx?Facility=TRACE&Product=CA&BreadCrumb=0202') filter_button = browser.find_element_by_id('ctl00_MainContentPlaceHolder_ctl00_FilterButton')   Traceback (most recent call last):  File "", line 1, in   File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 341, in find_element_by_id     return self.findelement(by=By.ID, value=id)  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 843, in find_element     'value': value})['value']  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute     self.error_handler.check_response(response)  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response     raise exception_class(message, screen, stacktrace) selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None Message:  browser.quit()

Let me know what else I can do to help you to reproduce the problem.

  From: Alexei Barantsev <notifications@github.com>

To: SeleniumHQ/selenium selenium@noreply.github.com Cc: isalsberg-mx isalsberg@yahoo.com; Author author@noreply.github.com Sent: Wednesday, October 18, 2017 6:24 AM Subject: Re: [SeleniumHQ/selenium] find_element_by_id throws exception in selenium 3.6.0 for python with FireFox 55+ (#4884)

For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.See CONTRIBUTING.md— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

p0deje commented 7 years ago

I cannot test because your website gives 403 Forbidden.

However, according to the failure, there is an alert shown on the page:

UnexpectedAlertPresentException: Alert Text: None

You need to handle alert first. So, you need to authorize your browser before accessing the website.

Closing since this works as expected. Please look for support in the selenium-users group.

isalsberg-mx commented 7 years ago

Have you read my previous post?

I told you it requieres a user/pwd to access and a certificate.

It is not an authentication problem because I do have the credentials to access the website. FF 54 does NOT give the find_element_by_id problem, so it is something with version 55+.

I can show you the error accessing live that specific website thru a remote session, since by obvious reasons I can not give you the credential to access the web site.

isalsberg-mx commented 7 years ago

If you want me, I can post the output of the very same code with the website using FF 54 showing find_element_by_id is working just fine.

Can you reopen the ticket or I have to create a new one with the same issue?

p0deje commented 7 years ago

Can you create a simple script that I can run to reproduce the error locally? I'm sure you can spend some time to come up with such a script and you don't even need to use your site - there are plenty of online sites with authentication (e.g. https://auth-demo.aerobatic.io/protected-standard/).

I'll reopen the issue once a reproducible test case is provided.

isalsberg-mx commented 6 years ago

I was able to reproduce the issue with the link you provided.

I was sending the basic authentication using the Extension AutoAuth 2.1.1. Turns out the problem in FF 55+ was caused by authenticating this way.

Nevertheless, If I implicitly send the authentication in the URL it works fine, by instance:

browser.get("https://aerobatic:aerobatic@auth-demo.aerobatic.io/protected-standard/") test=browser.find_element_by_id('examples') # Now it returns the object reference

The case can be closed.

Thanks for your help.