I have a ruby script that opens a browser. I have it set to open Firefox first and then Chrome if FF fails for some reason - like FF gets updated and Selenium hasn't caught up yet.
The wait function/definition works fine for FF but always breaks Chrome. Here is the relevant code for the Chrome browser startup:
b = Selenium::WebDriver.for :chrome
b.driver.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT
I'm fairly new to Selenium still and I user the wait.until command after declaring something like:
wait = Selenium::WebDriver::Wait.new(:timeout => $BROWSER_EXPLICIT_WAIT)
The above lines of code work fine in Firefox. However, I'd like to run my scripts with both FF and Chrome. Is there a way to do this in Chrome and FF?
Thanks
See now that you provide the error it gets easier to solve.
The reason is that - you have named the selenium driver instance as b
but defining the implicit time as
b.driver.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT
ie with b.DRIVER, hence the error message - undefined method 'driver' for
change your command to
b.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT
Related
I have just finished my project that uses Google Maps API. when I tested on my mobile it failed. I started debugging and it seems to be having problems getting the current position
navigator.geolocation.getCurrentPosition(function(position){ ... }, function(error){ ... }):
This line fails on Chrome and default browser, the callback function is never called (and I don't know how to see what error is thrown).
So I started using the Chrome emulator ( Refer to this ) and no error is being triggered. Everything works well.
And I am passing a second function to handle errors to getCurrentPosition and nothing is displayed... what would be the problem?! Do you know what can I do to make it work on my mobile? Any other test I can do?
I tested on different computers and it works
The settings allow me to share my current position
I am calling
Hyena.Store = DS.Store.extend({
revision: 11,
adapter: DS.RESTAdapter.extend()
});
It doesn't work Chrome browser with a heap of errors like Uncaught TypeError: Cannot call method 'extend' of undefined and DS.RESTAdapter has no method extend. Anyone have an idea why? It works fine in Safari and Firefox, but only loads 1 in 10 times in Chrome.
Edit: Adding one of the error outputs as requested:
Uncaught TypeError: Object [object Object] has no method 'setup' ember.js?body=1:29481
Ember.Application.Ember.Namespace.extend.setupEventDispatcher ember.js?body=1:29481
Ember.Application.Ember.Namespace.extend.didBecomeReady ember.js?body=1:29453
DeferredActionQueues.flush ember.js?body=1:4901
Backburner.end ember.js?body=1:4591
Backburner.run ember.js?body=1:4630
Ember.run ember.js?body=1:5112
(anonymous function) ember.js?body=1:29201
fire jquery.js?body=1:3065
self.fireWith jquery.js?body=1:3177
jQuery.extend.ready jquery.js?body=1:434
completed jquery.js?body=1:105
The solution was discovered in part thanks to #ahaurw01 - his mentioning that he could only reproduce in Chrome Canary lead me to check my Chrome version, which (for reason unknown) had 'dev' affixed to the version number. I re-downloaded Chrome from the website, removing that from the version, and it fixed the problem.
Still a concern for future releases of Chrome, but at least it's working for now.
When am trying to launch chrome browser using selenium it throws me error.
Am using this command in my code "selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.com/");
f you want to launch Google Chrome, you will have to use something else than "*chrome".
Using Selenium RC in interactive mode, with something like this
$ java -jar selenium-server.jar -interactive
and using the getNewBrowserSession command not correctly :
cmd=getNewBrowserSession
I get the list of browsers is supports :
23:43:09.317 INFO - Got result: Failed to start new browser session: Browser not supported:
(Did you forget to add a *?)
Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
on session null
So, I'm guessing you should be able to launch Google Chrome using "*googlechrome" instead of "*chrome".
-reference - sir pascal martin . :D
Are you using Selenium RC?
I use WebDriver, and the code that I used to open Chrome is:
System.setProperty("webdriver.chrome.driver", "<localpath of Chrome driver>");
WebDriver chromeobj = new ChormeDriver();
chromeobj.get("www.google.com");
I am using Netty websockets and everything seems to work fine except this minor issue :
If I close the browser / tab of the js websocket client , the websocket connection is automatcally closed when using Mozilla firefox (currently using firefox 14) but the same thing does not happen in Chrome 20/21.
Anyone seen a similar issue / can anyone tell why is the connection not closed automatically ?
I guess I should have checked this earlier in the chromium bug section but I was not sure if it is a bug.
It has been reported earlier by someone and a chromium bug already exists :
Issue 51687 : WebSocket: Send close with code 1001 on reload / tab close
Update : Someone has submitted a patch to fix this issue, can be seen in the above link.
This may not be right, but I cannot post a comment to your question. Chrome/Chromium does not really close if you have an App running and have selected "Continue running background apps when Chromium is closed" from Settings-->Under the hood.
It may be that it treats the websocket connection as an app. Try looking at your running processes and kill any chrome/chromium process you find.
Again, this is just speculation on my part.
Chrome doesn't close the connection, when a user will close the window or browser.
It will trigger an Error event.
A possible workaround could look like this:
#OnError
public void onErr(Throwable t) {
onClose(this.container.getWsSession(), null);
}
But this will close the connection every time, an Error is triggered. You may wan't to check the throwable, before closing the connection by yourself.
For more discussion, please join this question:
Websocket: Closing browser triggers onError() in chrome but onClose() event in Firefox
I am trying to run some simple tests on Chrome, and I have followed all required steps to do this. The tests start fine, the Chrome browser opens and is initialized correctly (it seems), but when my tests start to search for objects and check values on the web page.
(e.g.
[#browser.div(:id, "example").text.should == "test"]
or
[puts #browser.div(:id, "example").text]
) I get the next error and my tests fail: "Selenium::WebDriver::Error::UnkownError:".
This is it, only this message appears, with no clues or details on the error.
I simply do not know were to look for answers. I even tried to debug the tests but with no results.
I even search on known issues on chromedriver, but found nothing.
Another thing to mention is that the tests suite create by me is for cross browser testing.
These tests work fine on Firefox.
Am I doing something wrong in initializing the Chrome browser?
Here is the code from my env file:
require "rubygems"
require "rspec"
require "watir-webdriver"
require "watir-webdriver/extensions/alerts"
if ENV["HEADLESS"] then
include Selenium
capabilities = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
browser = Watir::Browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => capabilities)
elsif ENV["FIREFOX"] then
browser = Watir::Browser.new :firefox
elsif ENV["CHROME"] then
browser = Watir::Browser.new :chrome
elsif ENV["IE"] then
browser = Watir::Browser.new :ie
else
browser = Watir::Browser.new :chrome
end
Before do
#browser = browser
end
at_exit do
browser.close
end
I have tried also with the latest release in selenium-webdriver gem, and after this with an older version 2.21.0. Results are the same.
Can you give me a clue what am I doing wrong?
Thank you.
Well, obviously I did not checked with the latest version of chromedriver :).
The version from which the issue stops reproducing is the one from 23 of May 2012.
Thank you for the hint Ċ½eljko!