config file
I am unable to run my test in firefox with directconnect true. Please provide a solution
Versions:
Angular: 4
Protractor: 5.1.2
Selenium Standalone Server: 3.4.0
GeckoDriver: 0.18.0
Firefox Browser: 54.0
I modified your configuration file and use it as given below
exports.config =
{
framework: 'jasmine',
directConnect:true,
specs: ['spec4.js'],
capabilities: {
browserName: 'firefox',
}
};
Related
I've been tasked with writing different suites of tests and tasks automation but Protractor has been acting in a very strange way the past couple days and... I just don't recall having changed anything from the last time my suites ran correctly.
Currently using the latest drivers:
% ./node_modules/webdriver-manager/bin/webdriver-manager status
webdriver-manager: using local installed version 12.1.0
[09:14:25] I/status - selenium standalone version available: 3.13.0 [last]
[09:14:25] I/status - chromedriver version available: 2.40 [last]
[09:14:25] I/status - geckodriver version available: v0.21.0 [last]
[09:14:25] I/status - android-sdk is not present
[09:14:25] I/status - appium is not present
And what appears to be the latest Protractor version:
% ./node_modules/protractor/bin/protractor --version
Version 5.3.2
This is what Protractor's output looks like 80% of the time, when it doesn't run:
% ./node_modules/protractor/bin/protractor ./conf.js --suite scenarios --params.login.usr=$USR_E2E --params.login.pwd=$PWD_E2E --params.env=test
(node:1709) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[09:03:07] W/driverProviders - Using driver provider hosted, but also found extra driver provider parameter(s): seleniumServerJar
[09:03:07] I/launcher - Running 1 instances of WebDriver
[09:03:07] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[09:03:08] E/launcher - Error: NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"[type="email"]"}
(Session info: headless chrome=67.0.3396.99)
(Driver info: chromedriver=2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363),platform=Mac OS X 10.14.0 x86_64)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[09:03:08] E/launcher - Process exited with error code 100
The corresponding webdriver-manager's output:
% ./node_modules/webdriver-manager/bin/webdriver-manager start
webdriver-manager: using local installed version 12.1.0
[09:30:49] I/start - java -Dwebdriver.chrome.driver=/Users/cyril/Projects/parkopoly_e2e/node_modules/webdriver-manager/selenium/chromedriver_2.40 -Dwebdriver.gecko.driver=/Users/cyril/Projects/parkopoly_e2e/node_modules/webdriver-manager/selenium/geckodriver-v0.21.0 -jar /Users/cyril/Projects/parkopoly_e2e/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.13.0.jar -port 4444
[09:30:49] I/start - seleniumProcess.pid: 1791
09:30:49.534 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.13.0', revision: '2f0d292'
09:30:49.535 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-07-16 09:30:49.613:INFO::main: Logging initialized #282ms to org.seleniumhq.jetty9.util.log.StdErrLog
09:30:49.752 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
09:30:55.414 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--disable-extensions",
"--show-fps-counter=true",
"--disable-infobars",
"--incognito",
"--disable-gpu",
"--headless"
]
},
"count": 1
}
09:30:55.415 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363) on port 24866
Only local connections are allowed.
09:30:55.951 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:30:56.171 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 9ea12201cba04ac9e41639501f0c02e1 (org.openqa.selenium.chrome.ChromeDriverService)
09:30:56.925 INFO [ActiveSessions$1.onStop] - Removing session 9ea12201cba04ac9e41639501f0c02e1 (org.openqa.selenium.chrome.ChromeDriverService)
Here's the conf.js file I'm currently using:
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
SELENIUM_PROMISE_MANAGER: false,
rootElement: 'html',
seleniumServerJar: './bin/selenium-server-standalone-3.12.0.jar',
seleniumPort: '4444',
seleniumAddress: 'http://localhost:4444/wd/hub',
framework: 'jasmine2',
directConnect: false,
specs: ['./e2e/**/*.spec.js'],
suites: {
cft: './e2e/cft/**/*.spec.js',
scenarios: './e2e/scenarios/**/*.scenario.js'
},
jasmineNodeOpts: {
isVerbose: true,
defaultTimeoutInterval: 15000,
print: function() {}
},
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--disable-extensions', '--show-fps-counter=true', '--disable-infobars', '--incognito', '--disable-gpu', '--headless']
}
},
onPrepare: async function() {
browser.params.ts = Date.now();
if (browser.params.env === undefined)
browser.params.env = 'test';
await jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStackTrace: true,
displaySuccessful: true,
displayFailed: true,
displayPending: true,
displaySpecDuration: true,
displaySuiteNumber: true
},
summary: {
displayFailures: true,
displayPending: false
},
colors: {
enabled: true,
successful: 'green',
failed: 'red',
pending: 'yellow'
}
}));
await browser.get('https://dashboard-' + browser.params.env + '.website.com');
await browser.driver.findElement(by.css('[type="email"]')).sendKeys(browser.params.login.usr);
await browser.driver.findElement(by.css('[type="password"]')).sendKeys(browser.params.login.pwd);
await browser.driver.findElement(by.css('[type="submit"]')).click();
return await browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /calendar_bo/.test(url);
});
}, 10000);
}
};
Sometimes, whenever Protractor starts and launch the tests, it just suffers from race conditions.
I couldn't find any thread, post, comment or anyone that ever had such outputs. I'm running out of ideas and I'd appreciate any ideas or potential solutions. Thanks!
Have not enough reputation to comment..
Could it be that you have a seleniumServerJar AND a seleniumAddress configured at the same time? Documentation specifies to use only 1.
Protractor needs to know how to connect to Drivers for the browsers it
is testing on. This is usually done through a Selenium Server.
There are five options - specify one of the following:
seleniumServerJar - to start a standalone Selenium Server locally.
seleniumAddress - to connect to a Selenium Server which is already running.
sauceUser/sauceKey - to use remote Selenium Servers via Sauce Labs.
browserstackUser/browserstackKey - to use remote Selenium Servers via BrowserStack.
directConnect - to connect directly to the browser Drivers. This option is only available for Firefox and Chrome.
can you try this code before email send keys:
var EC = protractor.ExpectedConditions;
var email_element = element(by.css('[type="email"]'));
browser.wait(EC.visibilityOf(email_element), 10000);
How can we configure the selenium grid in protractor?
Do we need to create hub and node like how we do with selenium?
How can we run the "webdriver-manager" as hub/node?
Thanks
Harsh
Try the below configuration,
multiCapabilities: [
{
browserName: 'chrome',
seleniumAddress : "http://remotemachine1:4444/wd/hub"
},
{
browserName: 'firefox',
seleniumAddress : "http://remotemachine2:4444/wd/hub"
}
].
Before executing the test you need to start the selenium server using webdriver-manger start on both the remote machines.
I am having an issue running a test with 'multiCapabilities'. My multiCapabilities config is:
multiCapabilities: [{
browserName: 'chrome',
'name': 'LMB Decision Engine - UI Automation',
'tunnel-identifier': 'nonprod',
'parent-tunnel': 'LMSauceLabs'
}, {
browserName: 'chrome',
'name': 'LMB Decision Engine - UI Automation',
'tunnel-identifier': 'nonprod',
'parent-tunnel': 'LMSauceLabs'
}],
And the response that I get is:
[chrome #2] Failed: stale element reference: element is not attached to the page document
[chrome #2] (Session info: chrome=47.0.2526.73)
[chrome #2] (Driver info: chromedriver=2.20.353141 (da3cb4b52d3a04ce079546eac4dc96182f58602b),platform=Linux 3.13.0-32-generic x86)
However, when I run with this capabilities config it passes:
capabilities : {
'browserName': 'firefox',
'name': 'LMB Decision Engine - UI Automation',
'tunnel-identifier': 'nonprod',
'parent-tunnel': 'LMSauceLabs'
},
Has anyone seen this issue when running in parallel? I've tried all different combinations of browser, and disabling all of the plugins individually to see if they are incompatible with multiCapabilities, but the issue seems to be solely running in parallel version individually.
Thanks,
Tyler
If you are trying to run parallel tests in chrome you could use shardTestFiles:true in the multi capabilities config, like this:
multiCapabilities: [
{
browserName: 'chrome',
shardTestFiles: true,
// change this to the number of instances you want to run
maxInstances:2
}];
I want to build a Testsuite for an Angular App. The testsuite should use the framework "Protractor".
When I start the testsuite local with protractor local.config.js, then the test are running successful.
When I start the testsuite with BrowserStack without proxy, also everything are okay.
Now my question:
What settings do I have to do if I want to perform the test by local browser stack behind a proxy?
Main BrowserStack configuration:
var
proxy = 'http://proxy.example.com:8888';
exports.config = {
capabilities: {
project: 'BrowserStack (beyond Proxy)',
proxy: {
proxyType: 'manual',
httpProxy: proxy,
sslProxy: proxy,
},
loggingPrefs: {
driver: "FINE",
server: "OFF",
browser: "FINE"
},
'browserstack.user': 'USER_KEY',
'browserstack.key': 'ACCESS_KEY', // show on BrowserStack
// Needed for testing localhost
'browserstack.local' : 'true',
// Settings for the browser you want to test
// (check docs for difference between `browser` and `browserName`
'browserName' : 'chrome',
'version' : '43.0',
'os' : 'OS X',
'os_version' : 'Yosemite',
'resolution' : '1024x768'
},
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
specs: [
'test/e2e/**/*.spec.js'
]
};
I call the script "BrowserStackLocal" with this parameters:
./BrowserStackLocal -v -proxyHost PROXY_DOMAIN -proxyPort PROXY_PORT $ACCESS_KEY localhost,$PORT,0
Stepts:
start the application on my local computer node app.js
start the script "BrowserStackLocal"
start the protractor with the browserstack configuration from above.
When you are behind a proxy server, you need to do two things:
If you are testing your local server, you need to setup the Local Testing connection by passing the proxy details, which I assume you are doing.
You have to make sure the Selenium requests made via Protractor also reach BrowserStack. The easiest option would be to use global-tunnel npm package. If your proxy is behind an Authentication, you can try using the tunnel npm module.
You no longer need to use global-tunnel. There is now a new configuration option webDriverProxy:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
webDriverProxy: 'http://127.0.0.1:8888',
capabilities: {
browserName: 'chrome'
},
specs: ['*.spec.js'],
};
I am trying to use phantomjs without success :(
Using this sample as a testcase:
https://github.com/angular/protractor/blob/master/docs/page-objects.md
my protractor.conf.js looks like this:
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'phantomjs'
},
// Spec patterns are relative to the location of the spec file. They may
// include glob patterns.
suites: {
homepage: '*.spec.js',
search: ['tests/e2e/contact_search/**/*Spec.js',
'tests/e2e/venue_search/**/*Spec.js']
},
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
isVerbose:true,
includeStackTrace: true
}
,
specs: ['example_spec.js']
};
when I run this I get:
"C:\Program Files (x86)\JetBrains\WebStorm 8.0.4\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\lib\cli.js protractor.conf.js
Using the selenium server at http://localhost:4444/wd/hub
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was:
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:148:22)
at Function.webdriver.WebDriver.createSession (c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:122:30)
at Builder.build (c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:293:22)
at HostedDriverProvider.getDriver (c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\hosted.js:63:9)
at c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:238:41
at _fulfilled (c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:759:13)
at c:\Users\harry.redknapp\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:573:44
How can I get phantomjs working?