protractor actions.keydown vs selenium actions.keydown - selenium-webdriver

Protractor: 5.4.1
Selenium: 3.14
geckodriver: 0.23
browser: firefox
Hi, i am getting a error "Failed: sendKeysToActiveElement" when execute following code
browser.actions().keyDown(protractor.Key.CONTROL).click(elements).keyUp(protractor.Key.CONTROL).perform()
However if i am trying to run it with selenium instead of protractor, it work with the following code
driver.actions({bridge:true}).keyDown(webdriver.Key.CONTROL).click(elements).keyUp(webdriver.Key.CONTROL).perform();
Is anyone experience on this before?

The difference in the Protractor and Selenium JS code snippets is that the form doesn't perform the actions in bridge mode while the later does.
From the selenium source at v3.14,
* In bridge mode, {#link #perform perform()} will first attempt to execute the
* configured action sequence using the W3C action protocol. If this is rejected
* by the remote end, the sequence will be translated to and executed against
* the legacy protocol.
It seems that Gecko webdriver may not support the W3C action protocol and errors from the actions is thrown.
if (this.bridge_
&& (ex instanceof UnknownCommandError
|| ex instanceof UnsupportedOperationError)) {
return executeLegacy(this.executor_, this.sequences_);
}
throw ex;
Try running your actions in bridge mode for your Protractor tests.
actions = browser.actions({bridge: true})
actions.keyDown(protractor.Key.CONTROL)
.click(elements)
.keyUp(protractor.Key.CONTROL)
.perform()

Related

Use Existing Chrome Browser with remote-debugging-port using RobotFramework

I am trying to use existing google chrome instance using RobotFramework (SeleniumLibrary). I am starting the chrome instance like this
chrome.exe --remote-debugging-port=9289 --user-data-dir="D:\gcdata"
This my code in robotframework
${options}= Evaluat sys.modules['selenium.webdriver'].ChromeOptions() sys,selenium.webdriver
${prefs}= Create Dictionary debuggerAddress 127.0.0.1:9289
Call Method ${options} add_experimental_option prefs ${prefs}
Create WebDriver Chrome chrome_options=${options}
When I run the RobotFramework code, it invokes a new browser. Can anyone help me here telling what is going wrong and how to fix it.
Using the most recent versions of the Python Selenium Module, Chrome and ChromeDriver the following Robot script will connect to an already running chrome that is started using:
chrome.exe --remote-debugging-port=9289 --user-data-dir="C:\temp\gdata"
chrome_debugger.robot
*** Settings ***
Library SeleniumLibrary
Library Collections
*** Test Cases ***
TC
${ChromeOptions}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys,selenium.webdriver
# Method debugger_address is not callable so convert to Capabilities Dictionary and set it manually
${ChromeCapabilities}= Call Method ${ChromeOptions} to_capabilities
Set To Dictionary ${ChromeCapabilities["goog:chromeOptions"]} debuggerAddress 127.0.0.1:9289
# Instead of using the Chrome Options use Capabilities.
Create WebDriver Chrome desired_capabilities=${ChromeCapabilities}
Go To http://cnn.com
Even though the ChromeOptions class (GitHub) has the debugger_address(self, value) method, calling this method from Robot Framework returns an error. Therefore converting the ChromeOptions class to a Capabilities dictionary and adding it manualy to the dictionary before passing it to the webdriver through the desired_capabilities argument.

Firefox Webdriver fails with UnreachableBrowserException and blank Screen

I am running webdriver 2.53.1 against firefox 45.9.0ESR on Redhat Linux 6.6. FirefoxDriver object gets created successfully and firefox launches with blank page (about:blank) as expected. But when I do the 'get' to open the url, it fails with UnreachableBrowserException with underlying cause as org.apache.http.NoHttpResponseException: localhost:7055 failed to respond.
Preferences set for FirefoxProfile
app.update.auto = false
app.update.enabled = false
app.update.silent = false
media.gmp-provider.enabled = false
webdriver.log.file = webdriver_debug.log
webdriver.firefox.logfile = firefox_browser.log
My observations
Browser is running and is not killed
Browser has webdriver addon added.
By 'netstat' I see webdriver listening on port 7055
Though I configured to dump firefox and webdriver logs, nothing gets dumped.
What I tried so far
Handling the exception and retrying does not help
The firefox is a tar ball extract. I tried removing the folder and extracting again, but that did not help either.
Used navigate().to(url) instead of get(url) but result is same.
NOTE: The JRE 7 is used for running
Upgrading Selenium
We cannot upgrade the selenium or firefox as there are many other dependent layers to be upgraded for selenium/firefox to upgrade.
You need to update your jars files of selenium both server and client.
Download the latest jars from below link :-
http://www.seleniumhq.org/download/
You also need to update your gecko driver from below URL :-
https://github.com/mozilla/geckodriver/releases
Additionality update your firefox
Help -> About

not able to start nightwatch for testing WebRTC

I am new to selenium. Now, I am stumbled upon Nightwatch.js for testing WebRTC. I am trying out this link to start. Now I have set up accordingly. Now when I try to run, I am getting the following error
Starting selenium server... There was an error while starting the Selenium server:
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -host
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$1.setConfiguration(GridLauncherV3.java:219)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:147)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:73)
Following other links. I ran the following command
java -Dwebriver.chrome.driver="./bin/chromedriver" -jar bin/selenium-server-standalone-3.0.0.jar
And the selenium server started, but still when I run the test from Nightwatch, the error exists, Please help!

browser.debugger() doesn't pause browser

I am using WebStorm 9 and Protractor version 1.8. I prefer to use Chrome (version 41.0.2) for my debugging and am able to able to debug the normal application in Browser and also in WebStorm.
However debugging Protractor is failing.
Protractor --version //1.8.0
Angular // 1.3
OS // Windows 7
Here is a simple test
it('check title', function () {
browser.get('/e2e/employeeForm.html');
browser.sleep(5000);
browser.debugger();
var title = element(by.className('someClass'));
expect(title.getText()).toMatch('Employee Form');
});
In terminal, in one console I started webdriver webdriver-manager start. In other, I ran the command
protractor debug prc.conf.js
Following is the output:
Starting debugger agent.
debugger listening on port 5858
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
connecting... ok
break in timers.js:79
77 }
78
79 function listOnTimeout() {
80 var msecs = this.msecs;
81 var list = this;
debug>
I hit c and Enter. It continues and all tests fails. Even browser doesn't render my page. browser.debugger() is ignored.
Can anyone suggest me anything here?
There is a bug with protractor 1.8.0 and windows detailed here: https://github.com/angular/protractor/issues/1822
The bug has been fixed in master (https://github.com/angular/protractor/pull/1850), and will be released in the next version of protractor.

Is appcache not supported with selenium webdriver (JS implementation) using phantomjs?

We are running cucumber tests against our Single Page App using Selenium WebDriver and PhantomJS. We recently implemented an appcache manifest and now our cukes fail. In our troubleshooting it seems to be failing because phantomjs does not support cache manifests. In looking through the phantomjsdriver.log we that the negotiated capabilities contained:
"applicationCacheEnabled":false
We then tried to set the desired capabilities to enable it with:
var webdriver = require('selenium-webdriver');
var hooks = function() {
this.Before(function(callback) {
var pBrowser = webdriver.Capabilities.phantomjs();
pBrowser.set('applicationCacheEnabled', true);
this.driver = new webdriver.Builder().withCapabilities(pBrowser).build();
});
The desired vs negotiated capabilities in the log file show that it's trying to be set but isn't succeeding (and our cukes are still failing).
SessionManagerReqHand - _postNewSessionCommand - New Session Created: c6f61520-b603-11e3-83b0-2b905be08819
GhostDriver - Main - running on port 63911
CONSTRUCTOR - Desired Capabilities: {"browserName":"phantomjs","applicationCacheEnabled":true}
CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.1","driverName":"ghostdriver","driverVersion":"1.0.3","platform":"mac-unknown-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
Does anyone know if our scenario isn't supported or if we're implementing it the wrong way?
According to line #47 of the source code at http://bit.ly/1mrRvaV, GhostDriver does not support the feature of desired vs. negotiated capabilities.

Resources