I have done a lot of unit tests using Karma, but my office would like to have some integration tests, especially testing cross browser capabilities. For this, it seemed Protractor was my best option, and I have started get get some basic dashboard tests going, but am stuck with safari.
My Config:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['scenarios/*Scenario.js'],
framework: 'jasmine',
baseUrl: 'https://www-dev.remeeting.com/',
multiCapabilities: [{
browserName: 'firefox'
}, {
browserName: 'chrome'
}, {
browserName: 'safari'
}],
onPrepare: function() {
browser.driver.get('https://www-dev.remeeting.com/');
browser.driver.findElement(by.id('email')).sendKeys('adam+test#mod9.com');
browser.driver.findElement(by.id('password')).sendKeys('abc123');
browser.driver.findElement(by.id('submit_btn')).click();
// Login takes some time, so wait until it's done.
// For the test app's login, we know it's done when it redirects to
// app/#/d.
return browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /app\/#\/d/.test(url);
});
}, 10000);
}
};
My only spec
describe('Dashboard', function() {
it('should login to the dashboard', function() {
expect(element(by.css('.dashboard')).getText()).toMatch(/Upload Meeting/);
expect(element(by.id('refreshButton')));
expect(element(by.css('.dashboard div.btn-group')))
});
});
And the error
[safari #21] PID: 79079
[safari #21] Specs: /Users/adam/git/mrp- www/e2e/scenarios/dashboardScenario.js
[safari #21]
[safari #21] Using the selenium server at http://localhost:4444/wd/hub
[safari #21] ERROR - Unable to start a WebDriver session.
[safari #21] Unknown command: setTimeout (WARNING: The server did not provide any stacktrace information)
...
[safari #21] Driver info: org.openqa.selenium.safari.SafariDriver
[safari #21] Capabilities [{browserName=safari, takesScreenshot=true, javascriptEnabled=true, version=9.1, cssSelectorsEnabled=true, platform=MAC, secureSsl=true}]
[safari #21] Session ID: null
[launcher] Runner process exited unexpectedly with error code: 1
[launcher] 2 instance(s) of WebDriver still running
Anybody know how to configure protractor for safari?
Here is what I did to successfully set up Safari + Protractor:
made sure I have the latest Safari (9.1 at the moment)
downloaded the latest Safari driver from this page, opened the Safari extensions preferences and dragged and dropped the SafariDriver.safariextz file into the extension list:
upgraded protractor to the latest version (3.2.2 at the moment)
Note that, as an alternative, you can always run Safari remotely on BrowserStack or SauceLabs.
See also the list of Safari+Protractor issues.
Related
System Details
Mac OS, Chromedriver v=83.0.4103.39 , Protractor=7.0
My test is failing all the time when chromedriver opens any website it says your connection is not private please let me know how to fix this issue
chromedriver page
My spec.js looks like below
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
});
});
config.js looks like below
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
};
this is how my proxies look like
proxy settings in mac
Changes my config.js to
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec1.js'],
//acceptInsecureCerts : true
'args': ['--disable-web-security', '--user-data-dir=~/.e2e-chrome-profile', '--ignore-certificate-errors']
};
Still any URL like facebook.com or google.com I am getting err_invalid_cert err
My Nightwatch test suite was running just fine until I upgraded Ubuntu to 19.10. Now, when the browser launches from the test script I get an error message:
Failed to load extension from: . Manifest file is missing or unreadable
The Ubuntu install upgraded Chromium to 78.0.3904.70, and also switched to the snap version. I don't know which of these changes has caused the symptom I'm seeing.
I've upgraded chromedriver to match the same version as Chromium.
Chromium itself launches just fine as a browser, so the other solutions I've seen as search results, finding and deleting existing Chrome profiles, etc, I don't want to do. Ideally I'd like the browser that my nightwatch tests launch to be independent of any existing user profiles.
For reference, my Nightwatch config is:
// eslint-disable-next-line camelcase
const selenium_port = process.env.SELENIUM_PORT || 4444
const chromeArgs = process.env.SHOW_BROWSER ? [] : ['headless']
const driver = process.env.CHROMEDRIVER
module.exports = {
page_objects_path: './tests/e2e/page-objects',
test_settings: {
default: {
globals: {
waitForConditionTimeout: 5000
},
selenium_port,
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
args: chromeArgs
}
},
webdriver: {
server_path: driver
}
}
},
'selenium': {
'port': selenium_port
}
}
after some lost hours browsing internet, I'm not able to find the solution. I'm currently trying to test my app on older versions of Firefox (here, v41.0) for some reasons. I'm passing by a docker image of Selenium for the hub (v3.4.0) and a docker image for the Firefox node (v41.0).
I know that for older versions of Firefox, Geckodriver, isn't compatible but it seems having a solution using
{ "marionette": true }
The Firefox node is perfectly connecting to the grid. I can connect to it using docker exec -it <container-id> bash but the issue appears while running the test.
I'm still trying to find it but I'm blocked. Here the code of the Dockerfile: hub.docker.com/r/selenium/node-firefox/~/dockerfile/ for the Firefox node and here is the code for the test (using MochaJS).
test.it("should redirect to Google with FIREFOX 41.0", () => {
var firefoxCap = Capabilities.firefox();
firefoxCap.set('marionette', true);
driver = new webdriver.Builder()
.usingServer(CONSTANTS.SELENIUM_HUB)
.withCapabilities(firefoxCap)
.build();
driver.get(CONSTANTS.GOOGLE_URL);
driver.wait(until.titleIs(CONSTANTS.GOOGLE_TITLE));
driver.wait(until.elementLocated(By.name(CONSTANTS.GOOGLE_SEARCH_KEY))).sendKeys(CONSTANTS.GOOGLE_SEARCH_VALUE);
driver.findElement(By.name(CONSTANTS.GOOGLE_SEARCH_BUTTON_NAME)).click();
driver.wait(until.titleIs(CONSTANTS.GOOGLE_SEARCH_TITLE));
driver.wait(until.elementLocated(By.tagName(CONSTANTS.GOOGLE_RES_LINK))).click();
driver.wait(until.titleIs(CONSTANTS.GOOGLE_TITLE));
driver.quit();
});
Here the logs
~/dev/selenium-grids/src$ mocha --timeout 30000 tests.js
Starting the tests...
Work with REMOTE URL
1) should redirect to Google with FIREFOX 41.0
0 passing (6s)
1 failing
1) Work with REMOTE URL should redirect to Google with FIREFOX 41.0:
WebDriverError: Missing 'marionetteProtocol' field in handshake
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'd4b3266d29f4', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-87-generic', java.version: '1.8.0_131'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
0: 0x5787ed - backtrace::backtrace::trace::h59229d13f6a8837d
1: 0x578942 - backtrace::capture::Backtrace::new::h23089c033eded8f0
2: 0x450aec - geckodriver::marionette::MarionetteHandler::create_connection::h6f7058fccafe4367
3: 0x425c32 - <webdriver::server::Dispatcher<T, U>>::run::h8f5348b8f5f7c053
4: 0x40b22c - std::panicking::try::do_call::hb67c6fb6bcd96195
5: 0x5dc20a - panic_unwind::__rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:98
6: 0x41b943 - <F as alloc::boxed::FnBox<A>>::call_box::h4100941edc372034
7: 0x5d48a4 - alloc::boxed::{{impl}}::call_once<(),()>
at /checkout/src/liballoc/boxed.rs:650
- std::sys_common::thread::start_thread
at /checkout/src/libstd/sys_common/thread.rs:21
- std::sys::imp::thread::{{impl}}::new::thread_start
at /checkout/src/libstd/sys/unix/thread.rs:84
at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:517:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (node_modules/selenium-webdriver/lib/http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:169:7)
From: Task: WebDriver.createSession()
at Function.createSession (node_modules/selenium-webdriver/lib/webdriver.js:777:24)
at Function.createSession (node_modules/selenium-webdriver/firefox/index.js:667:55)
at createDriver (node_modules/selenium-webdriver/index.js:167:33)
at Builder.build (node_modules/selenium-webdriver/index.js:629:16)
at Context.test.it (tests_web.js:64:14)
at runTest (node_modules/selenium-webdriver/testing/index.js:164:22)
at node_modules/selenium-webdriver/testing/index.js:185:16
at new ManagedPromise (node_modules/selenium-webdriver/lib/promise.js:1085:7)
at controlFlowExecute (node_modules/selenium-webdriver/testing/index.js:184:14)
at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:3092:14)
at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:3075:27)
at asyncRun (node_modules/selenium-webdriver/lib/promise.js:2982:25)
at node_modules/selenium-webdriver/lib/promise.js:676:7
at <anonymous>
From: Task: Work with REMOTE URL should redirect to Google with FIREFOX 41.0
at Context.ret (node_modules/selenium-webdriver/testing/index.js:183:10)
Closing the tests
When googling the issue because "Google is your friend", the only responses are "Update your Firefox versions" or "Downgrade your Selenium version" but I can't. Can someone explain me how to make it work? Even a workaround would be accepted.
Thanks
While you work with Selenium 3.4.0 with Mozilla Firefox 41.0 you need to downgrade your geckodriver to either version v0.17.0 or v0.16.1 or v0.16.0.
The following were the last announced dependency:
geckodriver v0.18.0 now recommends Firefox 53 and greater
geckodriver v0.16.0 is only compatible with Selenium 3.4 and greater
Finally, assuming the geckodriver.exe absolute path is within your System/User Path you have to explicitly set the marionette property to false (mandatory)
Your code block will be looking like:
test.it("should redirect to Google with FIREFOX 41.0", () => {
var firefoxCap = Capabilities.firefox();
firefoxCap.set('marionette', false);
driver = new webdriver.Builder()
.usingServer(CONSTANTS.SELENIUM_HUB)
.withCapabilities(firefoxCap)
.build();
Java Code to open legacy Mozilla Firefox 47.0.1 (geckodriver v0.16.1) :
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Opening_FIREFOX_legacy
{
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver-v0.16.1-win64\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("firefox_binary", "C:\\Program Files\\Mozilla Firefox47\\firefox.exe");
dc.setCapability("marionette", false);
WebDriver driver = new FirefoxDriver(dc);
driver.manage().window().maximize();
driver.get("https://google.com");
}
}
Python Code to open legacy Mozilla Firefox 47.0.1 (geckodriver v0.18.0) :
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
binary = FirefoxBinary(r'C:\Program Files\Mozilla Firefox47\firefox.exe')
caps = DesiredCapabilities().FIREFOX
caps["marionette"] = False
driver = webdriver.Firefox(capabilities=caps, firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get('https://stackoverflow.com')
That's my question, every time I go to the console and try to restart the server by doing gulp, a new tab is open in the browser, so I have to close the one I have open and start working on the new one.
And another question regarding the same:
sometimes there is an error on the code styling and the tab is open anyways once you do gulp, but you can not start working on it until you fix the error on the code style, then you go and do gulp and the new tab comes up.
here is my gulpfile.js
var gulp = require('gulp');
var paths = {
sass: ['scss/**/*.scss'],
js: ['www/js/*.js', 'www/js/**/*.js', '!www/js/lib.min.js', '!www/js/code.min.js']
};
// Dev task
gulp.task('dev', ['sass', 'lint', 'compress-lib', 'compress-js', 'run-ionic'], function() { });
// Build task
gulp.task('default', ['dev', 'lint', 'sass', 'compress-lib', 'compress-js', 'watch']);
//Ionic Serve Task
gulp.task('run-ionic',shell.task([
'ionic serve'
]));
gulp.task('compress-lib', function() {
gulp.src([
'./www/lib/ionic/js/ionic.bundle.min.js'
])
.pipe(concat('lib.min.js'))
.pipe(gulp.dest('./www/js'))
.pipe(livereload());
});
gulp.task('compress-js', function() {
gulp.src([
'./www/js/app.js'
])
.pipe(ngAnnotate())
.pipe(concat('code.min.js'))
.pipe(gulp.dest('./www/js'))
.pipe(livereload());
});
// JSHint task
gulp.task('lint', function() {
gulp.src(paths.js)
.pipe(jscs())
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(livereload());
});
gulp.task('sass', function(done) {
gulp.src('./scss/ionic.app.scss')
.pipe(sass({onError: function(e) { console.log(e); } }))
.pipe(autoprefixer('last 2 versions', 'Chrome', 'ios_saf','Android'))
.pipe(gulp.dest('./www/css/'))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'))
.on('end', done)
.pipe(livereload());
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.js, ['lint', 'compress-lib', 'compress-js']);
livereload.listen(9000);
});
gulp.task('install', ['git-check'], function() {
return bower.commands.install()
.on('log', function(data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
});
});
Live Reload App During Development (beta)
The run or emulate command will deploy the app to the specified platform devices/emulators. You can also run live reload on the specified platform device by adding the --livereload option. The live reload functionality is similar to ionic serve, but instead of developing and debugging an app using a standard browser, the compiled hybrid app itself is watching for any changes to its files and reloading the app when needed. This reduces the requirement to constantly rebuild the app for small changes. However, any changes to plugins will still require a full rebuild. For live reload to work, the dev machine and device must be on the same local network, and the device must support web sockets.
With live reload enabled, an app's console logs can also be printed to the terminal/command prompt by including the --consolelogs or -c option. Additionally, the development server's request logs can be printed out using --serverlogs or -s options.
Command-line flags/options for run and emulate:
[--livereload|-l] ....... Live Reload app dev files from the device (beta)
[--consolelogs|-c] ...... Print app console logs to Ionic CLI (live reload req.)
[--serverlogs|-s] ....... Print dev server logs to Ionic CLI (live reload req.)
[--port|-p] ............. Dev server HTTP port (8100 default, live reload req.)
[--livereload-port|-i] .. Live Reload port (35729 default, live reload req.)
[--debug|--release]
While the server is running for live reload, you can use the following commands within the CLI:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit
if using browsersync
// Stop the browser from automatically opening
open: false
https://www.browsersync.io/docs/options
browserSync.init({
proxy: 'localhost:8000',
open: false,
browser: "google chrome",
files: [
'./**/*.php'
]
});
So for some reason, when I run protractor, Firefox (32 latest) just opens with an empty browser and doesn't navigate to the baseURL. The tests I have written work fine with chrome, but not with firefox. It probably has something to do with the way the conf file is set up. Any ideas?
Conf file:
exports.config = {
allScriptsTimeout: 11000,
specs: [
'e2e/*.js'
],
multiCapabilities: [
{
'browserName': 'firefox'
},
{
'browserName': 'chrome'
}
],
chromeOnly: false,
chromeDriver: 'e2e/chromedriver/',
baseUrl: 'http://localhost:9000/',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
Firefox 32 is broken with selenium <= 2.42.2
UPDATE Selenium 2.43 is out!
Need selenium 2.43 or newer version. Or downgrade Firefox back to version 31 or less.
Issue: https://code.google.com/p/selenium/issues/detail?id=7642
FYI output might look like this:
Using the selenium server at: http://localhost:4444/wd/hub
/home/username/e2e/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109
var template = new Error(this.message);
^
UnknownError: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
003407891246748webdriver-profile/extensions/fxdriver#googlecode.com
1409877425492 addons.xpi DEBUG Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous7362003407891246748webdriver-profile/extensions/webdriver-staging
1409877425492 addons.xpi DEBUG checkForChanges
1409877425502 addons.xpi DEBUG Directory state JSON differs:........