Protractor 7 does not go beyond 'Using FirefoxDriver directly...' - macos

I am unable to run e2e tests with protractor 7 with the following configuration
...
directConnect: true,
capabilities: {
browserName: 'firefox'
}
...
on my MacOS Catalina. I noticed the
webdriver-manager update
command from the project's package.json downloads the geckodriver-v0.29.1.
As mentioned in the title the logs do not go beyond Using FirefoxDriver directly... when I run the tests. How can I check logs in more details (is there a verbose option in protractor?), and how can I fix the issue ?

With Splaktars answer I was able to get Firefox to launch using the typical directConnect: true setting.
I had to download the geckodriver-v0.29.1-macos.tar.gz package from the Github Releases and extract the binary. Then I replaced the geckodriver-v0.29.1 binary previously downloaded through webdriver-manager with that copy from the package.
After that I launched my tests to make sure everything was still partially working and finally saw the MacOS security popup. I ran the command to remove the quarantine flag:
xattr -r -d com.apple.quarantine /path/to/geckodriver-v0.29.1
Relaunched the tests and finally Firefox popped up...
Thanks again to Splaktar, just made an account so I can't comment or upvote for help

It looks like there is a known issue in the v0.29.1 release notes:
https://github.com/mozilla/geckodriver/releases/tag/v0.29.1
Those point to some GeckoDriver macOS Notarization docs:
https://firefox-source-docs.mozilla.org/testing/geckodriver/Notarization.html
However that page say
Arbitrary software downloaded through other means, such as curl(1) is not affected by this change.
I don't get any security pop ups or warnings, just the hang that you see.
Running
xattr -r -d com.apple.quarantine /Users/splaktar/Git/app/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.29.1
Doesn't help.
In https://github.com/angular/protractor/issues/4253, there are a lot of old issues mentioned with Firefox and directConnect support. I tried using directConnect: false with a suggestion from that issue:
config.capabilities = {
'browserName': 'firefox',
'marionette': true,
'elementScrollBehavior': 1
};
config.directConnect = false;
config.seleniumAddress = 'http://localhost:4444';
config.localSeleniumStandaloneOpts = {
jvmArgs: ['-Dwebdriver.gecko.driver=node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.29.1']
};
I ran webdriver-manager start and then ran my tests, but that failed quickly with an error page's HTML in the console and From: Task: WebDriver.createSession() Process exited with error code 199.
I also tried setting
config.firefoxPath = '/usr/local/bin/firefox-bin';
after creating a symbolic link there to /Applications/Firefox.app/Contents/MacOS/firefox-bin. But that didn't help at all. Firefox never gets started. I tried with Firefox Developer Edition as well.
Still investigating...

Related

Error: No such file (sftp liximomo extension)

I have this problem when I upload a file on the server using the extension liximomo/vscode-sftp for visual studio code.
[error] Error: No such file
at SFTPStream._transform
at SFTPStream.Transform._read
at SFTPStream._read
How I can fix this problem? I tried to upload files to different servers, so I guess it's not a server-related problem but an extension.
There is a better fix on GitHub that works for upload and download via SFTP extension:
Do a search inside ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js for options.emitClose = false;
Add options.autoDestroy = false; after both instances.
- mrjcgoodwin commented 8 days ago
This is apparently a brand new problem that has been introduced into the newer versions of VS Code. I have FOUND A SOLUTION that seems to work well, by modifying a single line in the extension code. This is only valid for version 1.12.9 of the liximomo.sftp extension.
Here are the steps:
Shutdown / Quit VS Code.
Locate the following file:Mac OS X:
~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.jsWindows:C:\Users\account_name\.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\sftp.js
Make a backup copy of the file.
Modify line 388, which should be:if ( code === STATUS_CODE . OK ) { changing it to:if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) {
Save the file.
Relaunch VS Code; test by uploading or downloading from your sftp server. The error should not be present.
The alternative solution involves downgrading your version of VS Code. This is not desirable as you are not getting the latest fixes, security patches, etc..
See the following links regarding this issue:
https://github.com/liximomo/vscode-sftp/issues/266
https://github.com/liximomo/vscode-sftp/issues/569 (repeat)
https://gitmemory.com/issue/liximomo/vscode-sftp/915/827578565 (note, this site has a bad SSL certificate).
If you want to downgrade your VS Code; use this link to find the older versions:
https://code.visualstudio.com/updates/v1_55
CREDIT:
Bao from: https://blog.naver.com/PostView.nhn?blogId=pcgun70&logNo=222341271496
From their blog entry (translated by Google to English):
"At first, there was no solution, but Now, 12 hours later, the Holy
One appeared, who told me how to solve it.files that sftp cannot find
in the first place. There is a calling phrase, VScode is upgraded and
an error is called. It came out. Actually, I did not solve the
problem. Even if the file is not found, the same result as the
success process is exported. It is just a modification. It is
expected that a modified version will be released in the future."
Not an answer to the problem, but solution in another (simple) way:
install Run On Save VSCode extension
write a deploy.sh script along the lines
rsync -avz -e 'ssh -i /home/user/.ssh/id_rsa' --exclude '.history' --exclude '.vscode' --exclude '.git' --exclude '.gitignore' --exclude 'deploy.sh' ./ user#domain.net:/home/user/public_html/
add the following configuration to VSCode settings.json to trigger the deploy.sh script on file save:
"emeraldwalk.runonsave": {
"commands": [
{
"match": ".*",
"isAsync": false,
"cmd": "${workspaceFolder}/deploy.sh"
},
]
}
Just switch to the second one:
There is another solution only upgrading the ssh2 package from the extension.
You just need to go to the extension path:
Windows:
C:\Users\your-user\.vscode\extensions\liximomo.sftp-1.12.9
When you are there, change the version of ssh2 package on the package.json file to ^1.1.0. Finally, just run npm install.
You should restart VSCode.
Alternatively, you could use a fork of the repository that is active and fixing these issues: https://github.com/Natizyskunk/vscode-sftp

Cannot call non W3C standard command while in W3C mode (Selenium::WebDriver::Error::UnknownCommandError) with Selenium ChromeDriver in Cucumber Ruby

We have Cucumber Ruby automation framework where we run few tests on Chrome headless browser in a Docker on Jenkins. A few days ago we started receiving an error "This version of ChromeDriver only supports Chrome version 75" this time we were using ChromeDriver 2.46 and with google-chrome-unstable browser using the following command:
#Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update -y
RUN apt-get install -y google-chrome-unstable
RUN apt-get install unzip
# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_VERSION 2.46
ENV CHROMEDRIVER_VERSION 75.0.3770.8
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
# Download and install Chromedriver
RUN wget -q --continue -P $CHROMEDRIVER_DIR "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
ENV PATH $CHROMEDRIVER_DIR:$PATH
I have now updated chromedriver version to 75.0.3770.8 and browser to google-chrome-beta=75.0.3770.27-1
#Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update -y
RUN apt-get install -y google-chrome-beta=75.0.3770.27-1
RUN apt-get install unzip
# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_VERSION 75.0.3770.8
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
RUN echo $CHROMEDRIVER_DIR
# Download and install Chromedriver
RUN wget -q --continue -P $CHROMEDRIVER_DIR "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
ENV PATH $CHROMEDRIVER_DIR:$PATH
And now I can see the error as:
unknown command: Cannot call non W3C standard command while in W3C mode (Selenium::WebDriver::Error::UnknownCommandError)
Is it possible to disable W3C mode or download an older version of Chrome browser and driver that doesn't use it? I think the possibility to disable W3C check would be great.
All you have to do is just to disable the W3C when initializing the webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('w3c', False)
create_webdriver('Chrome', options=options)
Environment:
Chrome 75
ChromeDriver 75
This error message...
unknown command: Cannot call non W3C standard command while in W3C mode (Selenium::WebDriver::Error::UnknownCommandError)
...implies that the ChromeDriver was unable to call non W3C standard command while in W3C mode while initiating/spawning a new WebBrowser i.e. Chrome Browser session.
Here the main issue is, when ChromeDriver's client requests a W3C-compliant session but the response from ChromeDriver does not conform to the W3C spec, and causes errors in language APIs.
Analysis
As per the discussion in ChromeDriver response in W3C mode is not standard compliant John Chen (Owner - WebDriver for Google Chrome) mentioned that, Simon Stewart (Creator - WebDriver) had updated that:
The new session response for a w3c session should look like:
{
"value": {
"sessionId": "some-uuid",
"capabilities": {
"browserName": "chrome",
...
}
}
}
But when starting a new session with the w3c option set to true in the chromeOptions as follows:
Selenium/Python:
from selenium import webdriver
opt = webdriver.ChromeOptions()
opt.add_experimental_option('w3c', True)
driver = webdriver.Chrome(chrome_options=opt)
Selenium/Java:
{
"sessionId": "af4656c27fb94485b7872e1fc616923a",
"status": "ok",
"value": {
"browserName": "chrome",
...
}
}
The returned response looks like:
{
"sessionId": "af4656c27fb94485b7872e1fc616923a",
"status": "ok",
"value": {
"browserName": "chrome",
...
}
}
Which is neither a correctly formed response for the JSON Wire Protocol (where "status" would be an integer), nor a correctly formed W3C response and without a correctly formed response, the w3c compatible cannot be used.
Relevant part of the spec: https://w3c.github.io/webdriver/webdriver-spec.html#new-session
Relevant tests from spec: https://github.com/w3c/web-platform-tests/pull/5187
ChromeDriver version: 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b)
Chrome version: 60.0.3112.90 (Official Build) (64-bit)
This revision and this commit addressed this issue.
This usecase
As you are using ChromeDriver v75.x and Chrome v75.x and you are still seeing the same error, you need to pass the ExperimentalOption w3c as true exclusively as follows:
capabilities = { "chromeOptions" => {'w3c' => true} }
Update
Till ChromeDriver v74.x, Chrome and ChromDriver combo was running in w3c mode by default but there was bug with in the chromedriver/server/http_handler.cc. As per the details in goog:chromeOptions.w3c=false doesn't work for POST request with empty body:
Method HttpHandler::HandleCommand checks the value of the kW3CDefault constant instead of session goog:chromeOptions.w3c value. As a result, JSON Wire protocol support was broken, where POST requests with an empty body are allowed.
JSON Wire protocol will be in demand until displayed endpoint is resumed in the w3c mode. It should be noted that W3C WebDriver specification doesn't forbid the use of 'displayed' endpoint and this feature is actively used in some APIs.
As Is Element Displayed command is not part of W3C spec, but is still used by some APIs, and its functionality can be difficult to replicate in those APIs. This Change List [revision and commit] re-enables this command in W3C mode to ease transition to W3C mode.
#John have already confirmed us to expect an update to ChromeDriver v75.0 tomorrow with the fix.
Here's the solution
As promised by John Chen [Owner - WebDriver for Google Chrome], ChromeDriver versions 75.0.3770.90 and 76.0.3809.25 have been released, and are now available at the ChromeDriver Downloads site. These versions include the following bug fixes over the previous releases of ChromeDriver 75 and 76:
Fixed a bug that incorrectly rejected POST requests with empty body in OSS mode
Added new endpoints for retrieving Chrome log
In addition, version 76.0.3809.25 also includes the following change:
Added endpoint for Is Displayed command in W3C mode
Snapshot
If you are getting this error using rails + rspec + capybara + selenium, the way to pass the option to disable W3C is as follows:
Capybara.register_driver :chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: {'w3c' => false}
)
Capybara::Selenium::Driver.new(app, :browser => :chrome, desired_capabilities: capabilities)
end
Just add w3c: false in the end like in this example:
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: ["window-size=#{DEFAULT_X_RES},#{DEFAULT_Y_RES}"], w3c: false })
For my PHP friends who search the depths of the internet...
The newest version of PHPUnit_Extensions_Selenium2TestCase
Which is at the moment a composer constraint of
"phpunit/phpunit-selenium": ">=7",
"phpunit/phpunit": ">=6"
Can use the following options. Note my struggle::
'w3c' => false
This must be a boolean and not a string.
class NavigationTest extends PHPUnit_Extensions_Selenium2TestCase
{
public function setUp()
{
static $count;
$count or $count = 1 and print PHP_EOL . 'java -jar ' . dirname(__DIR__) . '/selenium-server-standalone-3.141.59.jar' . PHP_EOL;
self::shareSession(true);
$this->setDesiredCapabilities([
"chromeOptions" => [
'w3c' => false
]
]);
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowser('chrome');
$this->setBrowserUrl('http://localhost:9919/');
$this->prepareSession()->currentWindow()->maximize();
}
}
Not sure what framework you're using but i have the same error after updating my browser & chromedriver to latest one v75.0.3770.90. My suggestion is that looking for the session init section in your scripts and add the option to disable w3c.
E.g mine before upgrading:
chrome_options = Selenium::WebDriver::Chrome::Options.new
options[:options] = chrome_options
Capybara::Selenium::Driver.new(app, options)
after upgrading
chrome_options = Selenium::WebDriver::Chrome::Options.new
chrome_options.add_option('w3c',false)
options[:options] = chrome_options
Capybara::Selenium::Driver.new(app, options)
In my case it was different version of selenium that not supported w3c. Decrease chromedriver to version 74.0.3729.6 make all work work. It could also be fixed by updateing selenium version to latest that support W3C.
Please start reading documentation instead of "just disabling" something that is there for a reason.
For example, executing scripts:
/session/{session id}/execute/sync
/session/{session id}/execute/async

Not able to change default download directory for chrome with selenium hub docker and ruby watir

After a few days of searching and experimenting with any of the solutions I could find online, I give up and want to get some help from the community.
Ruby gems (ruby 2.5.1):
watir 6.11.0
selenium-webdriver 3.4.1
Docker:
selenium/node-chrome-debug:3.14
selenium/hub:3.14
My ruby code:
prefs = {
download: {
prompt_for_download: false,
default_directory: download_directory
}
}
browser = Watir::Browser.new(:chrome, url: selenium_hub_url, options: {prefs: prefs})
Our set-up is:
Run a selenium/hub and a selenium/node-chrome-debug. Something that might be different is that we are mounting the /tmp of the base OS as /hosttmp/tmp in the node container
Make the selenium/node-chrome-debug talk to selenium/hub
Make the browser automation talk to the selenium/hub using the code provided above
The problem is that I was never able to set the default download directory. However, all other parts are working correctly. The VNC window shows the browser is working correctly despite the default download directory settings. It is always /home/seluser/Downloads
Things I have tried:
Other people's ideas such as different ways to specify the options and preferences. (e.g. using the Capabilities)
Docker security-related settings such as: --privileged --security-opt apparmor:unconfined --cap-add SYS_ADMIN
On the base OS, chmod 777 for the download_directory. The download_directory, for example, /tmp/tmp.123 on the base OS, which is mounted as /hosttmp/tmp/tmp.123 in the chrome node container, I could see it and make a few read/write operations in this folder inside the container or on the base OS
Tweaks about the interesting ruby symbol/string stuff when creating a Hash object.
Does anyone have more ideas about what could lead to this situation? What else I could try? And is there any log that I could refer to. There is no error or warning when running the code. Thanks in advance.
I'm using Java+Docker+Selenium+Chrome for automation test and also met similar issue with you. Please find my solutions below and try if it works for your case.
Don't set default download directory in the options, just leave "/home/seluser/Downloads" as it is.
When you start up the chrome node on docker, please add the parameter of volume that could transfer the downloaded files to the directory you want.
e.g. docker run -d -p 5900:5900 --link myhub:hub -v :/home/seluser/Downloads selenium/node-chrome-debug:3.14.0
In my case, the JDK environment and my test script is on Linux machine while the selenium webdriver & browser are all on docker, so once the file downloaded by browser it cannot saved directly on Linux machine, you have to mount the local directory with default directory on docker. Then you could find the file saved in the directory you want.
Thanks & Regards!
Jing
Did you define options = Selenium::WebDriver::Chrome::Options.new?
We use
options = Selenium::WebDriver::Chrome::Options.new
prefs = {
prompt_for_download: false,
default_directory: download_directory
}
options.add_preference(download: prefs)
and then you would want something like
browser = Watir::Browser.new(:chrome, url: selenium_hub_url, options: options)
But maybe the main problem is just that you are using
options: {prefs: prefs}
instead of
options: {download: prefs}
Okay, by digging into the source code of the Watir and Selenium-Webdriver, I think I know the 'root cause'.
I have created an issue since I am not sure if this is a bug or a 'feature' The issue
Also, I have a workaround for my case, in watir/capabilities.rb:
Change
#selenium_browser = browser == :remote || options[:url] ? :remote : browser
to
#selenium_browser = browser == :remote ? :remote : browser
This shouldn't be the final solution as it might not be a good idea. Will wait for what the Watir people say about this.

Protractor - disable 'harmful' download message on chrome

I'm trying to download a file in my test. I've managed to start the download without getting the download prompt.
the problem now is that I'm getting a warning saying that "This type of file can harm your computer.Do you want to keep...anyway?" and I need to choose 'Discard' or 'Keep'.
I've tried to find chromeOptions for that - unsuccessfully.
currently using those args:
args: ['--disable-popup-blocking="true", --allow-unchecked-dangerous-downloads="true", --disable-download-notification="true"']
any ideas?
Took me a day of googling and almost gave up... but i found a solution from How to disable 'This type of file can harm your computer' pop up
Will post the solution here since it was frikin hard to track it down when using protractor as the keyword
prefs = {
'safebrowsing' => {
'enabled' => true,
}
}
oddly enough, you need to "turn on" safe browsing to make the message dissapear
Try the following flags:
--safebrowsing-disable-download-protection
--safebrowsing-disable-extension-blacklist.

Running casperjs tests with slimerjs

I wrote a few tests with casperjs. They run just fine with phantomjs. However, when I tried to use slimerjs with the following command:
casperjs --verbose --engine=slimerjs test create-project-suite.js
A small window appers with the SlimerJs logo and version number but the console seems to hang with the following line:
Test file: create-project-suite.js
Is there anything else I need to do? Here are the version numbers:
Mozilla Firefox 28.0
CasperJS version 1.1.0-beta3
Innophi SlimerJS 0.9.1
3.8.0-37-generic #53~precise1-Ubuntu
Update:
I removed code until I got slimerjs to open the browser and execute tests. It seems that it hangs whenever I require a js file (I'm following the page objects pattern):
var Login = require('./objects/login');
I think require.paths could be helpful. Any ideas on how to get around this?
Using full paths makes slimerjs happy:
var path = fs.absolute(fs.workingDirectory + '/objects/login');
var Login = require(path);
It is plain simpler to move all modules to the same directory where the script is.
I tried your command and it works for me, maybe in your file you use an instruction specific to phantom :
http://docs.slimerjs.org/0.8/differences-with-phantomjs.html
But it should open the window(at least the start() ).
Anyway the command is fine.

Resources