I've been trying to open tabs in browsers via Selenium and seems to work on all except Safari.
I'm trying the following:
public void openNewTab(String url) {
((JavascriptExecutor) getWebDriver()).executeScript("window.open('" + url + "','_blank');");
}
I've seen some answers in other languages to pass the --legacy argument but not an equivalent for Java.
Any hints?
Update
Some related answers include:
Request body does not contain required parameter 'handle'
Here's the error I'm getting when trying the code on the following OS via SauceLabs:
Mac 10.13
Mac 10.14
iPad Pro (12.9 inch) Simulator
org.openqa.selenium.InvalidArgumentException: Request body does not contain required parameter 'handle'.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'itako4501.prod.miso', ip: 'fe80:0:0:0:ca0:e26a:55bf:fecd%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '9.0.4'
Driver info: driver.version: unknown
Command duration or timeout: 0 milliseconds
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:903)
Caused by: org.openqa.selenium.InvalidArgumentException: Request body does not contain required parameter 'handle'.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'itako4501.prod.miso', ip: 'fe80:0:0:0:ca0:e26a:55bf:fecd%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '9.0.4'
Driver info: driver.version: unknown
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'x-r', ip: 'fe80:0:0:0:4ac:2f6c:527b:c271%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '11.0.3'
Driver info: driver.version: unknown
This will open a new tab. tried on MacOs Mojave safari Version 12.1.2 (14607.3.9)
driver.get("http://google.com");
((JavascriptExecutor) driver).executeScript("window.open('http://cnn.com','_blank');");
Related
Mac
Version: 0.19.1
Platform: mcos Sierra
Firefox: 47.0
Selenium: 3.6
This is the issue..
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:40.131Z' System info: host: 'Darshans-MacBook-Air.local', ip: 'fe80:0:0:0:410:539:c982:328d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '9.0.1' Driver info: driver.version: FirefoxDriver remote stacktrace: stack backtrace: 0: 0x10405749e -
From geckodriver releases, with the geckodriver v0.19.0, is recommended to use Firefox 55.0 (and greater).
So, is simple thought that with the 0.19.1 should be (at least) the same. Try to update your firefox.
I am getting the error below when trying to run Protractor test against chrome.
session not created exception: Chrome version must be >= 59.0.3071.0
[11:42:23] E/launcher - session not created exception: Chrome version must be >= 59.0.3071.0 (Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide
any stacktrace information) Command duration or timeout: 6.44 seconds Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z' System info: host: 'PC328569', ip: '10.25.227.179', os.name: 'Windows 7', os.arch: 'amd64', os.version:
'6.1', java.version: '1.8.0_121' Driver info: driver.version: unknown [11:42:23] E/launcher - SessionNotCreatedError: session not created exception: Chrome version must be >= 59.0.3071.0 (Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows
NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 6.44 seconds Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z' System info: host: 'PC328569', ip:
'10.25.227.179', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121' Driver info: driver.version: unknown at WebDriverError (D:\Balachander\DailyScript\node_modules\selenium-webdriver\lib\error.js:27:5) at SessionNotCreatedError
(D:\Balachander\DailyScript\node_modules\selenium-webdriver\lib\error.js:214:5) at Object.checkLegacyResponse (D:\Balachander\DailyScript\node_modules\selenium-webdriver\lib\error.js:505:15) at parseHttpResponse (D:\Balachander\DailyScript\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (D:\Balachander\DailyScript\node_modules\selenium-webdriver\lib\http.js:440:13) at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: WebDriver.createSession() at Function.createSession (D:\Balachander\DailyScript\node_modules\selenium-webdriver\lib\webdriver.js:777:24)
at Function.createSession (D:\Balachander\DailyScript\node_modules\selenium-webdriver\chrome.js:709:29) at createDriver (D:\Balachander\DailyScript\node_modules\selenium-webdriver\index.js:167:33) at Builder.build (D:\Balachander\DailyScript\node_modules\selenium-webdriver\index.js:623:16)
at Hosted.getNewDriver (D:\Balachander\DailyScript\node_modules\protractor\lib\driverProviders\driverProvider.ts:60:29) at Runner.createBrowser (D:\Balachander\DailyScript\node_modules\protractor\lib\runner.ts:225:39) at q.then.then (D:\Balachander\DailyScript\node_modules\protractor\lib\runner.ts:391:27)
at _fulfilled (D:\Balachander\DailyScript\node_modules\q\q.js:834:54) at self.promiseDispatch.done (D:\Balachander\DailyScript\node_modules\q\q.js:863:30) at Promise.promise.promiseDispatch (D:\Balachander\DailyScript\node_modules\q\q.js:796:13) [11:42:23]
E/launcher - Process exited with error code 199
Versions of the executables used:
webdriver manager - 12.0.6
protractor - 5.1.2
chrome driver - 2.32
Java - 1.8
What I have tried:
1.Updating the webdriver to latest version
npm update -g protractor
webdriver-manager update
2.Editing Protractor's config file: node_modules/protractor/config.json
Changing the chrome driver version to whatever you need. eg. "chromedriver": "2.24".Run webdriver-manager update.
But for some reason webdriver-manager always uses chrome driver 2.32.
Any help or suggestion is appreciated. Thanks.
As per Below references you need to update your actual installed chrome.
Update chrome by :- About Google Chrome
Menu -> Help ->
Refer :-
https://github.com/appveyor/ci/issues/1600
Chromedriver error "Chrome version must be >= 52" using Nightwatch
Hope it will help you :)
My protractor scripts are highly stable on chrome browser but the same scripts throws below mentioned for 20% of the test cases.
Failed: JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 100 milliseconds
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'LAPTOP-RNQ2JQBE', ip: '192.168.89.115', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=true, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:41897/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
Session ID: f32d0eb8-65d9-4161-9535-da5cde8b9a6c
Failed: Error while waiting for Protractor to sync with the page:
"Unable to get property '$$testability' of undefined or null
reference"
Dears stackoverflowers.
I have stuck with Selenium tests run locally.
ChromeDriver v2.7.236900 (32)
Chrome version Version 55.0.2883.87 m (64-bit)
Operation system is Windows 10 (64)
I just run this code:
open("http://anypage.com");
and get an error:
Using CustomChromeDriverProvider
Starting ChromeDriver (v2.7.236900) on port 3431
java.lang.IllegalArgumentException: org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'aliakseiPC', ip: '10.6.170.169', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: RemoteWebDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, chrome={userDataDir=C:\Users\ALIAKS~1\AppData\Local\Temp\scoped_dir10772_6183}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=55.0.2883.87, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 4a396df3b78d4da050e77cc00f493f3a
I am using protractor to test angular 1.3.13 and ui-grid 3.0. All cells in grid are editable. In my tests I can get cell using following method:
dataCell: function( gridId, fetchRow, fetchCol ) {
var row = this.getGrid( gridId ).element(by.css('.ui-grid-render-container-body')).element( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index').row( fetchRow ) );
return row.element( by.repeater('(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name').row( fetchCol ));
}
from https://github.com/angular-ui/ng-grid/blob/master/test/e2e/gridTestUtils.spec.js.
After I get first cell from first row, when I try to send value to cell
cell.click();
cell.sendKeys("newCellValue");
test breaks. I get following error message:
- Failed: unknown error: cannot focus element
(Session info: chrome=40.0.2214.115)
(Driver info: chromedriver=2.14.313457
(3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 3.13.0-49-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 35 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'xxxxxxxxx', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-49-generic', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/tmp/.com.google.Chrome.LHfq2F}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=40.0.2214.115, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 50857fdfa10a4bc75444d21f2d04359e
(Session info: chrome=40.0.2214.115)
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 3.13.0-49-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 35 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'xxxxxxxxx', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-49-generic', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/tmp/.com.google.Chrome.LHfq2F}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=40.0.2214.115, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 50857fdfa10a4bc75444d21f2d04359e
at /usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:102:16
at [object Object].promise.ControlFlow.runInFrame_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
at [object Object].promise.Callback_.goog.defineClass.notify (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
at [object Object].promise.Promise.notify_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
The problem occurs when sendKeys method is called. Does anyone know the correct way to change cell value using protractor?
Solved it. You need to focus cell and access input element:
cell.click();
cell.element(by.css(".ui-grid-cell-focus input")).sendKeys("newCellValue");
EDIT:
Has some issues on older browser versions, better to use:
cell.click();
cell.element(by.css("input")).sendKeys("newCellValue");
EDIT:
Another issue is with Firefox where cell.click() is not working properly.
Workaround/hack: https://stackoverflow.com/a/23370177