I have set up protractor on my machine by installing protractor globally via npm. Then I have updated my webdriver manager and started it.
Now running protractor protractor-e2e.conf.js works as it should when I have
capabilities: {
'browserName': 'firefox'
},
but for
capabilities: {
'browserName': 'chrome'
},
I get just a popup telling me:
An administrator has installed Google Chrome on this system, and it is available for all users. The system-level Google Chrome will replace your user-level installation now.
How can I resolve this? Should I reinstall Google Chrome? I really would like to test Chrome rather then Firefox...
I have uninstalled chrome, deleted both directories in
c:\Users\user_name\AppData\Local\Google\Chrome\
c:\Program Files (x86)\Google\Chrome\
And it works nicely now.
Related
Since we are facing problems with running headless Serenity tests using the installed Firefox browser on a Jenkins Server running on RedHat Linux machine, we installed XVFB to run the tests.
Our preferred browser to test is with Chrome, not Firefox. But Chrome is not available for RedHat Linux (Jenkins) Server.
Question, is do we need to have the Chrome browser installed on the Linux machine in order to run headless tests using XVFB ?
Yes, you need to have both the chrome browser and chrome driver to run tests. You can find the chrome driver [here][http://chromedriver.chromium.org/downloads]. If Chrome is not available for Red Hat Edition, you can install open source chromium.
When running tests, I would like not to be bothered by Chrome popping-up every time Behat launches a scenario needing Chrome.
I know there is a maximizeWindow() method for session objects, but nothing like "minimize".
Nowadays, you can set Chrome to run in headless mode like so (behat.yml):
default:
extensions:
Behat\MinkExtension:
javascript_session: browser
sessions:
browser:
selenium2:
browser: chrome
capabilities:
chrome:
switches:
- "--headless"
You could run Chrome with a virtual framebuffer, so that the window appears on a virtual screen instead of your real screen.
This also allows to easily run your tests on a headless machine, such as a build server.
On Linux, we're using xvfb for this particular purpose. More info: How To Run Your Tests Headlessly with Xvfb
For Windows, see Is there anything like xvfb or xnest for Windows?
Seems there is no method for launching in background. maximizeWindow is for setting the resolution.
You should try to run in a virtual machine or on another PC in order to avoid this kind of issues, popups and interacting by mistake with the window that runs automation.
Running on the same machine should be done when writing new tests and when debugging.
I found an acceptable solution for this that didn't require me to run Chrome headless or in a virtual machine.
Simply log in with a secondary user account on your local machine, and run selenium on that account. Then, switch back to your main user account and run your tests. The chrome browser will be created under the user running selenium and you will never see the chrome windows pop up.
I'm getting the following error when running my protractor test on mac for safari
Failed to connect to SafariDriver after 10082 ms
Build info: version: '2.53.1', revision: 'a36b8b1',
os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_101'
Driver info: driver.version: SafariDriver
capability:
name: 'Safari',
browserName: 'safari',
logName: 'Safari',
shardTestFiles: true,
maxInstances: 2
Do we need a specific safari driver for this? If yes, where can I get it from and where should it be declared in the .conf file.
Thank you!
Yes, you need to install a specific safari driver in order to launch it inside of protractor. And of course, you need to be on a mac. Protractor is essentially a layer built on top of Selenium, so you need to install the selenium driver for Safari, which is implemented as a Safari plugin.
Here is what you need to do:
Download the safari plugin from here.
Run the plugin
Select "Trust" the plugin when prompted by safari
The driver is now installed and should be available to your protractor process.
This is the driver for Selenium 2.48. I couldn't find a more recent build, so if this driver version doesn't run with the current version of Protractor, you will need to either use an older version of protractor that is based on Selenium 2.48 or build the safari driver from source.
First of all, starting with Safari 10, Safari comes bundled with a new driver implementation. The old driver (the extension) is deprecated. You're using macOS 10.12.2, so it's your case. To enable the new driver in Safari, toggle the Allow Remote Automation checkbox in the Develop menu. If you don't have this menu, enable it: Preferences > Advanced > Show Develop menu in menu bar. Start /usr/bin/safaridriver once manually to grant it the permissions needed.
Secondly, you need a 3.x version of the Selenium Standalone Server, not 2.53.1. The command to install it:
sudo webdriver-manager update --versions.standalone 3.0.1
To start:
webdriver-manager start --versions.standalone 3.0.1
Thirdly, the visibility checks are broken in the new driver. So things like browser.wait(ExpectedConditions.visibilityOf(myElement), 5000); don't work and lead to UnsupportedCommandException. In order to fix this, you can try installing Safari Technology Preview and running tests there (add 'safari.options': { technologyPreview: true } to the capabilities). But for me, the preview works even worse than the release. Protractor says it can't find Angular on the page because they changed window.name to be cleared after a cross-origin navigation in the Release 19. If you happen to find a way to make it work, please let me know.
Below are some links you should check because I might have missed something.
The blog post that announces the new driver in Safari 10
Issues in the Protractor project:
Safari 10 failing with the latest protractor
Safari Technology Preview can't find Angular 1
I want to debug Jasmine tests launched by Karma. In my karma.conf.js I have the following:
port: 9090,
urlRoot: '/',
autoWatch: false,
browsers: ['PhantomJS'],
So you can see that I specified PhantomJS as a browser to start. When I run tests in Run mode, PhantomJS is started. However, when I run tests in Debug mode, the Chrome browser is started and tests are actually executed in Chrome, instead of PhantomJS. Besides, I have these confusing log entries from Karma server:
13:42:36.239:INFO [launcher]: Starting browser PhantomJS
13:42:37.987:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#MpnkVSEn2B33WWVTAAAA with id 88994634
Here is my configuration:
Chrome is started as it's the only browser debugging is supported for. Debugging in PhantomJS is not supported; if you miss it, please vote for WEB-6072
I have a karma.config.js file in a repo that lists different browsers that karma needs to run test on. If I run the test on ubuntu which doesn't have safari install and karma will complain
No binary for Safari browser on your platform. Please set "SAFARI_BIN" env variable.
How do I configure Karma to automatically skip the browser without giving error if a browser is not installed. I don't want everyone who download the repo to edit the config file.
Let me answer my own question. After some searching and experimenting. I found a karma plugin that Karma detect browsers. In the karma config, I added
detectBrowsers: {
enable: true,
},
and removed the browsers array.
You still have to install the runners for each of the potential browser that you want to test on.
When I run karma now, it will try out different browsers and see if they are installed in the current system. If installed, run the test.