Selenium with Ruby - Chrome stalling during first set of APIs loading - selenium

I am currently using Selenium webdriver (4.1.0) with Ruby (2.6.6) and Chromedriver version is (v103).
After browser initialization, I have a login page and then a list page.
The driver passes through the Login page and stalls on the API for the List page.
This is the error
Net::ReadTimeout with #<TCPSocket:(closed)>
# /var/lib/jenkins/.gem/ruby/2.6.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/default.rb:124:in `response_for'
# /var/lib/jenkins/.gem/ruby/2.6.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/default.rb:77:in `request'
# /var/lib/jenkins/.gem/ruby/2.6.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
# /var/lib/jenkins/.gem/ruby/2.6.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/bridge.rb:588:in `execute'
# /var/lib/jenkins/.gem/ruby/2.6.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/bridge.rb:93:in `get'
# /var/lib/jenkins/.gem/ruby/2.6.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/navigation.rb:32:in `to'
# /var/lib/jenkins/.gem/ruby/2.6.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:143:in `get'
# /var/lib/jenkins/.gem/ruby/2.6.0/bundler/gems/Tarspect-c21e5368bc71/lib/tarspect/WebActions.rb:133:in `navigate_to'
I have increasing the Timeout but to no end.
Any Suggestions are highly appreciated !!

Related

capybara firefox 48 is giving error

Updated the firefox to version 48 but it give the following error. Any help how to solve it:
Selenium::WebDriver::Error::WebDriverError: unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/firefox/launcher.rb:90:in connect_until_stable'
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/firefox/launcher.rb:55:inblock in launch'
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/common/socket_lock.rb:43:in locked'
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/firefox/launcher.rb:51:inlaunch'
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/firefox/bridge.rb:43:in initialize'
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/common/driver.rb:53:innew'
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/common/driver.rb:53:in for'
from /Library/Ruby/Gems/2.0.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver.rb:86:infor'
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.6.2/lib/capybara/selenium/driver.rb:13:in browser'
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.6.2/lib/capybara/selenium/driver.rb:45:invisit'
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.6.2/lib/capybara/session.rb:232:in visit'
from /Library/Ruby/Gems/2.0.0/gems/capybara-2.6.2/lib/capybara/dsl.rb:51:inblock (2 levels) in '
from /Users/mesutgunes/scripts/capybara.rb:53
from /usr/bin/irb:12:in `'
Firefox v48 is not usable (in Capybara) without selenium-webdriver v3 and geckodriver. There is a beta version of selenium-webdriver v3 but it is currently missing a number of critical features (can't read the current value of form element for instance) and isn't really ready for real testing use yet. Downgrade to 47 for now.

The Chrome browser opens but does not go to the page

The error (s) are
C:\Users\kclarke\workspace\Watir>cucumber features
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
Starting ChromeDriver (v2.4.226107) on port 9515
[5988:6436:0216/144720:ERROR:gpu_info_collector_win.cc(146)] Could not read gaming score from assessment results.
[5988:6436:0216/144720:ERROR:chrome_views_delegate.cc(176)] NOT IMPLEMENTED
[5988:6436:0216/144720:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENTED
[2636:7124:0216/144735:ERROR:ipc_channel_win.cc(405)] pipe error: 232
unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.1 SP1 x86_64) (Selenium::WebDriver::Error::UnknownError)
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/bridge.rb:634:in `raw_execute'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/bridge.rb:99:in `create_session'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
Chrome Driver (version v2.4.226107 ) installed in path: C:\Ruby200\bin;C:\Users\kclarke\workspace\bin
My Code looks like this :
require 'rubygems'
require 'watir-webdriver'
##browser = Watir::Browser.new :firefox
#browser = Watir::Browser.new :chrome
##browser = Watir::Browser.new :ie
#browser.goto 'http:XXXXXXXXXXXXXXXXX'
First, this has nothing to do with wrong PATH, as clearly you can see from the message, ChromeDriver can be started successfully.
Then I'd suggest upgrade your ChromeDriver first before doing anything else, as your version is way out of date. From the changelog here, version 2.4 is 5 months old and the latest is 2.9, which supports Chrome 31-34. (Version 2.4 claims to support Chrome 32, but your Chrome 32.0.1700.107 m now is the latest, which wasn't the one when ChromeDriver 2.4 was released.)

Rescuing Redis Exception in Rails

I currently have a Rails 3.2.13 app using redis as its cache_store and for Sidekiq.
I'm also using redis master-slave. I ran into an issue where during failover a slave would be in the process of becoming master, Rails then connected to this node and once it tried to write to the node, even though the node was master, this exception was raised:
Redis::CommandError: READONLY You can't write against a read only slave.
vendor/bundle/ruby/1.9.1/gems/redis-3.0.4/lib/redis/client.rb:85:in `call'
vendor/bundle/ruby/1.9.1/gems/redis-3.0.4/lib/redis.rb:1181:in `block in srem'
vendor/bundle/ruby/1.9.1/gems/redis-3.0.4/lib/redis.rb:36:in `block in synchronize'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
vendor/bundle/ruby/1.9.1/gems/redis-3.0.4/lib/redis.rb:36:in `synchronize'
vendor/bundle/ruby/1.9.1/gems/redis-3.0.4/lib/redis.rb:1180:in `srem'
vendor/bundle/ruby/1.9.1/gems/redis-namespace-1.3.0/lib/redis/namespace.rb:306:in `method_missing'
vendor/bundle/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/manager.rb:123:in `block in clear_worker_set'
vendor/bundle/ruby/1.9.1/gems/connection_pool-1.0.0/lib/connection_pool.rb:48:in `with'
vendor/bundle/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq.rb:67:in `redis'
vendor/bundle/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/manager.rb:118:in `clear_worker_set'
vendor/bundle/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/manager.rb:45:in `block in stop'
vendor/bundle/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/util.rb:15:in `watchdog'
vendor/bundle/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/manager.rb:33:in `stop'
vendor/bundle/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/calls.rb:25:in `public_send'
vendor/bundle/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/calls.rb:25:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/calls.rb:125:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/actor.rb:328:in `block in handle_message'
vendor/bundle/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/tasks.rb:42:in `block in initialize'
vendor/bundle/ruby/1.9.1/gems/celluloid-0.14.0/lib/celluloid/tasks/task_fiber.rb:9:in `block in create'
I know the issue could easily be resolved by disconnecting anything that's using redis (e.g. sidekiq, rails cache_store) so that any subsequent commands that write to that node would reconnect with a valid connection.
The issue is where to catch and handle the exception? My initial thought was to do an airbrake kind of global rescue but not sure if that would be the best way to go about it.
Has anyone run into this issue?

Undefined method failure_app for nil:NilClass

I am trying to use devise from a Rails app to grant access to a Sinatra application within the Rack middleware.
My config/routes.rb has:
authenticate "admin" do
mount Admins::Dashboard, :at => "/admins"
end
In my Sinatra app, I use:
before do
env["warden"].authenticate!(:scope => "admin")
end
get "/dashboard" do
erb :dashboard
end
Now, I get an error with the following stacktrace:
Started GET "/admins/dashboard" for 127.0.0.1 at 2012-10-11 08:45:13 +0200
NoMethodError (undefined method `failure_app' for nil:NilClass):
devise (2.1.2) lib/devise/delegator.rb:11:in `failure_app'
devise (2.1.2) lib/devise/delegator.rb:5:in `call'
warden (1.2.1) lib/warden/manager.rb:130:in `call_failure_app'
warden (1.2.1) lib/warden/manager.rb:116:in `process_unauthenticated'
warden (1.2.1) lib/warden/manager.rb:47:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
The error message is a complaint about missing configuration for customizing the warden failure app to point to sinatra.
Check out this previous answer and the related (detailed) blogpost about setting up Sinatra+Warden & Rails+Devise; hopefully the instructions there will help you implement the solution successfully.
Had the same error message and this comment on Github helped me out.
In my sessions_controller.rb I had:
sign_in(:user, #resource, store: false, bypass: false)
which I replaced with:
sign_in(:users, #resource, store: false, bypass: false)
for it to work.
Specifically, the issue was only happening after one user would delete his account... Also I am using devise_token_auth (hence the overriden sessions controller).

jruby multipart post fails for files larger than 800k or so

I have a jruby application deployed using glassfish-gem with an apache front end. When I do a form post of a file it fails on files over a certian size, seems to be around 800k. The error is below if it helps any.
glassfish.yml is generated, no changes from default other than to increase some java memory settings.
I have bypassed apache and gone straight to the app but still have issues. Enabling threading in rails makes the problem worse.
INFO: /!\ FAILSAFE /!\ Fri Oct 29 04:54:17 +0000 2010
Status: 500 Internal Server Error
Stream closed
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/rack-1.1.0/lib/rack/utils.rb:466:in `parse_multipart'
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/rack-1.1.0/lib/rack/request.rb:268:in `parse_multipart'
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/rack-1.1.0/lib/rack/request.rb:146:in `POST'
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/facebooker-1.0.75/lib/rack/facebook.rb:38:in `call'
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/actionpack-2.3.10/lib/action_controller/session/cookie_store.rb:100:in `call'
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/actionpack-2.3.10/lib/action_controller/failsafe.rb:26:in `call'
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
/var/www/LocalHabit/shared/bundle/jruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:106:in `call'
/usr/local/rvm/gems/jruby-head/gems/glassfish-1.0.3.dev-universal-java/lib/../lib/rack/adapter/rails.rb:133:in `call'
/usr/local/rvm/gems/jruby-head/gems/glassfish-1.0.3.dev-universal-java/lib/../lib/rack/handler/grizzly.rb:55:in `call'
:1
Oct 29, 2010 4:54:17 AM com.sun.grizzly.http.SocketChannelOutputBuffer flushChannel
FINEST: flushChannel isAsyncHttpWriteEnabled=false bb=java.nio.HeapByteBuffer[pos=0 lim=1088 cap=33368]
Turns out there was a bug introduced in jruby version 1.5.1, that is supposedly fixed in 1.5.6, but I misplaced the details on the bug. It was actually related to a post issue in jruby in general.