Skip to content

Instantly share code, notes, and snippets.

@tourdedave
Last active November 29, 2016 04:06
Show Gist options
  • Save tourdedave/39ec50e57e8876e6a214991c2d15c38d to your computer and use it in GitHub Desktop.
Save tourdedave/39ec50e57e8876e6a214991c2d15c38d to your computer and use it in GitHub Desktop.
"""
The element lookup for the assertion fails.
Adding a sleep of 0.5 seconds before it makes it work.
But this example worked without the sleep in 2.53.1 with Firefox 46.
Using:
- selenium 3.0.2
- geckodriver 11.0.1
- Firefox 50.0.1
"""
import pytest
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
class TestLogin():
@pytest.fixture
def driver(self, request):
_geckodriver = os.path.join(os.getcwd(), 'vendor', 'geckodriver')
driver_ = webdriver.Firefox(executable_path=_geckodriver)
def quit():
driver_.quit()
request.addfinalizer(quit)
return driver_
def test_valid_credentials(self, driver):
driver.get("http://the-internet.herokuapp.com/login")
driver.find_element(By.ID, "username").send_keys("tomsmith")
driver.find_element(By.ID, "password").send_keys("SuperSecretPassword!")
driver.find_element(By.CSS_SELECTOR, "button").click()
assert(driver.find_element(By.CSS_SELECTOR, ".flash.success").is_displayed())
Exception `IO::EINPROGRESSWaitWritable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.3/lib/selenium/webdriver/common/socket_poller.rb:81 - Operation now in progress - connect(2) would block
Exception `Errno::ECONNREFUSED' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.3/lib/selenium/webdriver/common/socket_poller.rb:81 - Connection refused - connect(2) for 127.0.0.1:4444
["127.0.0.1", 4444]
1480392333706 geckodriver INFO Listening on 127.0.0.1:4444
Exception `IO::EINPROGRESSWaitWritable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.3/lib/selenium/webdriver/common/socket_poller.rb:81 - Operation now in progress - connect(2) would block
Exception `Errno::EISCONN' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.3/lib/selenium/webdriver/common/socket_poller.rb:81 - Socket is already connected - connect(2) for 127.0.0.1:4444
-> POST session
>>> http://127.0.0.1:4444/session | {"desiredCapabilities":{"browserName":"firefox","browserVersion":"any","platformName":"any","platformVersion":"any","acceptSslCerts":false,"pageLoadStrategy":"normal","moz:firefoxOptions":{}}}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"192"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
1480392333963 mozprofile::profile INFO Using profile path /var/folders/sk/gfclf5qj1vv_z4frjbvhr62w0000gn/T/rust_mozprofile.FWtqrp3s65QP
1480392333964 geckodriver::marionette INFO Starting browser /Applications/Firefox.app/Contents/MacOS/firefox-bin
1480392333967 geckodriver::marionette INFO Connecting to Marionette on localhost:58578
1480392334456 Marionette INFO Listening on port 58578
1480392335414 Marionette INFO startBrowser d62a949d-0d81-cc42-970a-75d807791fb4
<- {"sessionId":"d62a949d-0d81-cc42-970a-75d807791fb4","value":{"XULappId":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","acceptSslCerts":false,"appBuildId":"20160624030212","browserName":"Firefox","browserVersion":"50.0a1","command_id":1,"device":"desktop","pageLoadStrategy":"normal","platform":"DARWIN","platformName":"Darwin","platformVersion":"14.5.0","processId":55768,"proxy":{},"raisesAccessibilityExceptions":false,"rotatable":false,"specificationLevel":0,"takesElementScreenshot":true,"takesScreenshot":true,"version":"50.0a1"}}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/url
>>> http://127.0.0.1:4444/session/d62a949d-0d81-cc42-970a-75d807791fb4/url | {"url":"http://the-internet.herokuapp.com/login"}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"49"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/element
>>> http://127.0.0.1:4444/session/d62a949d-0d81-cc42-970a-75d807791fb4/element | {"using":"css selector","value":"#username"}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"44"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {"value":{"element-6066-11e4-a52e-4f735466cecf":"effc5bce-1c71-af4c-a202-f574b0b22a15"}}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/element/effc5bce-1c71-af4c-a202-f574b0b22a15/value
>>> http://127.0.0.1:4444/session/d62a949d-0d81-cc42-970a-75d807791fb4/element/effc5bce-1c71-af4c-a202-f574b0b22a15/value | {"value":["t","o","m","s","m","i","t","h"]}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"43"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/element
>>> http://127.0.0.1:4444/session/d62a949d-0d81-cc42-970a-75d807791fb4/element | {"using":"css selector","value":"#password"}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"44"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {"value":{"element-6066-11e4-a52e-4f735466cecf":"fdac55df-fbd1-7a42-a242-de008cb30732"}}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/element/fdac55df-fbd1-7a42-a242-de008cb30732/value
>>> http://127.0.0.1:4444/session/d62a949d-0d81-cc42-970a-75d807791fb4/element/fdac55df-fbd1-7a42-a242-de008cb30732/value | {"value":["S","u","p","e","r","S","e","c","r","e","t","P","a","s","s","w","o","r","d","!"]}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"91"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/element
>>> http://127.0.0.1:4444/session/d62a949d-0d81-cc42-970a-75d807791fb4/element | {"using":"css selector","value":"button"}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"41"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {"value":{"element-6066-11e4-a52e-4f735466cecf":"eecae28d-5418-0d49-911c-2eaa1a073e8b"}}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/element/eecae28d-5418-0d49-911c-2eaa1a073e8b/click
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {}
-> POST session/d62a949d-0d81-cc42-970a-75d807791fb4/element
>>> http://127.0.0.1:4444/session/d62a949d-0d81-cc42-970a-75d807791fb4/element | {"using":"css selector","value":".flash.success"}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"49"}
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
<- {"error":"no such element","message":"Unable to locate element: .flash.success"}
Exception `Selenium::WebDriver::Error::NoSuchElementError' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.3/lib/selenium/webdriver/remote/response.rb:70 - Unable to locate element: .flash.success
-> DELETE session/d62a949d-0d81-cc42-970a-75d807791fb4
Exception `IO::EAGAINWaitReadable' at /Users/tourdedave/.rbenv/versions/2.2.5/lib/ruby/2.2.0/net/protocol.rb:153 - Resource temporarily unavailable - read would block
[GFX1-]: Receive IPC close with reason=AbnormalShutdown
[Child 55769] ###!!! ABORT: Aborting on channel error.: file /builds/slave/m-cen-m64-ntly-000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2053
[Child 55769] ###!!! ABORT: Aborting on channel error.: file /builds/slave/m-cen-m64-ntly-000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2053
<- {}
#<ChildProcess::Unix::ForkExecProcess:0x007ff322918008 @args=["/Users/tourdedave/Dropbox/_dev/selenium-guidebook/code-examples-ruby/06_your_first_test/03/vendor/geckodriver", "--binary=/Applications/Firefox.app/Contents/MacOS/firefox-bin", "--port=4444"], @started=true, @exit_code=nil, @io=#<ChildProcess::Unix::IO:0x007ff322913d50 @stdout=#<IO:<STDOUT>>, @stderr=#<IO:<STDERR>>>, @cwd=nil, @detach=false, @duplex=false, @leader=false, @environment={}, @pid=55767> : [{:pid=>nil, :status=>nil}]
#<ChildProcess::Unix::ForkExecProcess:0x007ff322918008 @args=["/Users/tourdedave/Dropbox/_dev/selenium-guidebook/code-examples-ruby/06_your_first_test/03/vendor/geckodriver", "--binary=/Applications/Firefox.app/Contents/MacOS/firefox-bin", "--port=4444"], @started=true, @exit_code=nil, @io=#<ChildProcess::Unix::IO:0x007ff322913d50 @stdout=#<IO:<STDOUT>>, @stderr=#<IO:<STDERR>>>, @cwd=nil, @detach=false, @duplex=false, @leader=false, @environment={}, @pid=55767> : ["sending TERM"]
#<ChildProcess::Unix::ForkExecProcess:0x007ff322918008 @args=["/Users/tourdedave/Dropbox/_dev/selenium-guidebook/code-examples-ruby/06_your_first_test/03/vendor/geckodriver", "--binary=/Applications/Firefox.app/Contents/MacOS/firefox-bin", "--port=4444"], @started=true, @exit_code=nil, @io=#<ChildProcess::Unix::IO:0x007ff322913d50 @stdout=#<IO:<STDOUT>>, @stderr=#<IO:<STDERR>>>, @cwd=nil, @detach=false, @duplex=false, @leader=false, @environment={}, @pid=55767> : ["polling 20 seconds for exit"]
#<ChildProcess::Unix::ForkExecProcess:0x007ff322918008 @args=["/Users/tourdedave/Dropbox/_dev/selenium-guidebook/code-examples-ruby/06_your_first_test/03/vendor/geckodriver", "--binary=/Applications/Firefox.app/Contents/MacOS/firefox-bin", "--port=4444"], @started=true, @exit_code=nil, @io=#<ChildProcess::Unix::IO:0x007ff322913d50 @stdout=#<IO:<STDOUT>>, @stderr=#<IO:<STDERR>>>, @cwd=nil, @detach=false, @duplex=false, @leader=false, @environment={}, @pid=55767> : [{:pid=>nil, :status=>nil}]
#<ChildProcess::Unix::ForkExecProcess:0x007ff322918008 @args=["/Users/tourdedave/Dropbox/_dev/selenium-guidebook/code-examples-ruby/06_your_first_test/03/vendor/geckodriver", "--binary=/Applications/Firefox.app/Contents/MacOS/firefox-bin", "--port=4444"], @started=true, @exit_code=nil, @io=#<ChildProcess::Unix::IO:0x007ff322913d50 @stdout=#<IO:<STDOUT>>, @stderr=#<IO:<STDERR>>>, @cwd=nil, @detach=false, @duplex=false, @leader=false, @environment={}, @pid=55767> : [{:pid=>55767, :status=>#<Process::Status: pid 55767 SIGTERM (signal 15)>}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment