I'm experiencing some problem while E2E testing an AngularJS app with Protractor. To sum things up: I have the following specification and the first step always fails with a btstrpd error. (The page is auto-bootstrapped and we use AngularJS v1.3.0 and Protractor v2.1.0.)
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://myapp.abc.de/ext/#/login');
expect(browser.getTitle()).toEqual('My App');
});
it('should do other stuff', function() {
// ...
});
});
Error:
1) Protractor Demo App should have a title
Message:
UnknownError: unknown error: [ng:btstrpd] http://errors.angularjs.org/1.3.15/ng/btstrpd?p0=document
(Session info: chrome=43.0.2357.132)
(Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9 milliseconds
(Full description here)
Since I don't seem to find a solution to prevent this error and the remaining test steps run without any problems, my approach would be to simply ignore the error. However I don't want the test case to fail due to it. This brings me to my question: How can I catch this error so that the test won't fail? A plain try-catch around the two statements in the step does not the trick and since I don't have any promises here I also cannot do the typical promise error handling as one would manually handle e.g. a NoSuchElementError.
Edit - Error in webdriver console:
12:06:18.975 INFO - Executing: [new session: Capabilities [{count=1, browserName
=chrome}]])
12:06:18.995 INFO - Creating a new session for Capabilities [{count=1, browserNa
me=chrome}]
Starting ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) on
port 23267
Only local connections are allowed.
12:06:21.248 INFO - Done: [new session: Capabilities [{count=1, browserName=chro
me}]]
12:06:21.271 INFO - Executing: [set script timeoutt: 11000])
12:06:21.281 INFO - Done: [set script timeoutt: 11000]
12:06:21.390 INFO - Executing: [get: data:text/html,<html></html>])
12:06:21.405 INFO - Done: [get: data:text/html,<html></html>]
12:06:21.425 INFO - Executing: [execute script: window.name = "NG_DEFER_BOOTSTRA
P!" + window.name;window.location.replace("http://myapp.abc.de/ext/#/login");, [
]])
12:06:23.440 INFO - Done: [execute script: window.name = "NG_DEFER_BOOTSTRAP!" +
window.name;window.location.replace("http://myapp.abc.de/ext/#/login");, []]
12:06:23.458 INFO - Executing: [execute script: return window.location.href;, []
])
12:06:23.468 INFO - Done: [execute script: return window.location.href;, []]
12:06:23.489 INFO - Executing: [execute async script: try { return (function (at
tempts, asyncCallback) {
var callback = function(args) {
setTimeout(function() {
asyncCallback(args);
}, 0);
};
var check = function(n) {
try {
if (window.angular && window.angular.resumeBootstrap) {
callback([true, null]);
} else if (n < 1) {
if (window.angular) {
callback([false, 'angular never provided resumeBootstrap']);
} else {
callback([false, 'retries looking for angular exceeded']);
}
} else {
window.setTimeout(function() {check(n - 1);}, 1000);
}
} catch (e) {
callback([false, e]);
}
};
check(attempts);
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10]])
12:06:25.603 INFO - Done: [execute async script: try { return (function (attempt
s, asyncCallback) {
var callback = function(args) {
setTimeout(function() {
asyncCallback(args);
}, 0);
};
var check = function(n) {
try {
if (window.angular && window.angular.resumeBootstrap) {
callback([true, null]);
} else if (n < 1) {
if (window.angular) {
callback([false, 'angular never provided resumeBootstrap']);
} else {
callback([false, 'retries looking for angular exceeded']);
}
} else {
window.setTimeout(function() {check(n - 1);}, 1000);
}
} catch (e) {
callback([false, e]);
}
};
check(attempts);
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10]]
12:06:25.633 INFO - Executing: [execute script: return (function () {
angular.module('protractorBaseModule_', []).
config(['$compileProvider', function($compileProvider) {
if ($compileProvider.debugInfoEnabled) {
$compileProvider.debugInfoEnabled(true);
}
}]);
}).apply(null, arguments);, []])
12:06:25.643 INFO - Done: [execute script: return (function () {
angular.module('protractorBaseModule_', []).
config(['$compileProvider', function($compileProvider) {
if ($compileProvider.debugInfoEnabled) {
$compileProvider.debugInfoEnabled(true);
}
}]);
}).apply(null, arguments);, []]
12:06:25.663 INFO - Executing: [execute script: angular.resumeBootstrap(argument
s[0]);, [[protractorBaseModule_]]])
12:06:26.093 WARN - Exception thrown
org.openqa.selenium.WebDriverException: unknown error: [ng:btstrpd] http://error
s.angularjs.org/1.3.15/ng/btstrpd?p0=document
(Session info: chrome=43.0.2357.134)
(Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7
d3),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any
stacktrace information)
Command duration or timeout: 10 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'xxxxx', ip: 'xxx.xxx.xx.x', os.name: 'Windows 7', os.arch: '
amd64', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEn
abled=false, chrome={userDataDir=C:\Users\abcdefg\AppData\Local\Temp\scoped_dir1
1436_18156}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true,
version=43.0.2357.134, platform=XP, browserConnectionEnabled=false, nativeEvents
=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true,
browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsE
nabled=true}]
Session ID: 0c39849d960cccef7ec7036b8414c9fb
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.
java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHa
ndler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:599)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDri
ver.java:508)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(Even
tFiringWebDriver.java:101)
at com.sun.proxy.$Proxy1.executeScript(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.executeScript
(EventFiringWebDriver.java:213)
at org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteS
cript.java:53)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession
.java:168)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
12:06:26.103 WARN - Exception: unknown error: [ng:btstrpd] http://errors.angular
js.org/1.3.15/ng/btstrpd?p0=document
(Session info: chrome=43.0.2357.134)
(Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7
d3),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any
stacktrace information)
Command duration or timeout: 10 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'xxxx', ip: 'xxx.xxx.xx.x', os.name: 'Windows 7', os.arch: '
amd64', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEn
abled=false, chrome={userDataDir=C:\Users\abcdefg\AppData\Local\Temp\scoped_dir1
1436_18156}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true,
version=43.0.2357.134, platform=XP, browserConnectionEnabled=false, nativeEvents
=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true,
browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsE
nabled=true}]
Session ID: 0c39849d960cccef7ec7036b8414c9fb
12:06:26.203 INFO - Executing: [delete session: f947352d-3b40-4b1b-a46a-9d4ffe32
8b76])
12:06:27.417 INFO - Done: [delete session: f947352d-3b40-4b1b-a46a-9d4ffe328b76]
In your code, I would put a WaitforAngular() to make sure the sync append with Angular & Protractor. See bellow for reference:
it('should have a title', function() {
browser.get('http://myapp.abc.de/ext/#/login');
browser.waitForAngular();
expect(browser.getTitle()).toEqual('My App');
});
Then if it does not work, I would use the browser.pause(); command. This will break the execution of protractor where you use the command. From there you can open the Chrome debuging console to see what is appening exactly.
You can also use the REPL debuging mode it is very convenient way to check that you element are present on the page and that you are using the correct selector.
Please refer to the following link for more informations on debugging with protractor: https://angular.github.io/protractor/#/debugging
Related
I want to launch and perform actions like enter username details in application
but my execution is failing again and again because of error
My Code
public class VerifyProjectFromApp {
WebDriver driver;
AppLaunch toDoistAppLaunch;
HomePage homePage;
LoginPage login;
#BeforeMethod
public void startapplication() {
toDoistAppLaunch= new AppLaunch(driver);
this.driver=toDoistAppLaunch.launchApplication();
}
#Test
public void verifyCreatedProjectInApp() {
try{
//-Read create project value from properties file
Properties prop = new Properties();
InputStream input = null;
input = new FileInputStream(System.getProperty("user.dir") +
File.separator +"TodoistInputData.properties");
prop.load(input);
//-Read uuid from properties file
String email_id = prop.getProperty("email_id");
System.out.println("\t" + "email_id =" + email_id + "\r\n");
//-Read project name from properties file
String password = prop.getProperty("password");
System.out.println("\t" + "projectName =" + password + "\r\n");
login = new LoginPage(driver);
homePage = new HomePage(driver);
login.loginInApplication(email_id, password);
Utils.waitForPageLoadingToComplete(driver);
homePage.clickOnSideMenu();
Utils.pauseTestExecution(10);
} catch (Exception e) {
e.printStackTrace();
}
}
===================================================
public class LoginPage {
public static final String packageName = "com.todoist";
AndroidDriver<MobileElement> driver;
public LoginPage(WebDriver driver){
this.driver = (AndroidDriver<MobileElement>)driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
#AndroidFindBy(id=packageName+":id/btn_welcome_continue_with_email")
MobileElement continueButtonWithGmail;
#AndroidFindBy(id=packageName+":id/email_exists_input")
MobileElement enterEmailId;
#AndroidFindBy(id=packageName+":id/log_in_password")
MobileElement enterPassword;
#AndroidFindBy(id=packageName+":id/btn_continue_with_email")
MobileElement loginwithGmail;
#AndroidFindBy(id=packageName+":id/btn_log_in")
MobileElement loginButton;
public void clickOnContinueButtonWithGmail() {
continueButtonWithGmail.click();
}
public void enterEmailAddress(String emailId) {
enterEmailId.sendKeys(emailId);
}
public void enterPassword(String pass) {
enterPassword.sendKeys(pass);
}
public void clickOnGmailButton() {
loginwithGmail.click();
}
public void clickOnLoginButton() {
loginButton.click();
}
public void loginInApplication(String emailId,String password) {
try {
clickOnContinueButtonWithGmail();
Utils.waitForPageLoadingToComplete(driver);
enterEmailAddress(emailId);
Utils.waitForPageLoadingToComplete(driver);
clickOnGmailButton();
Utils.waitForPageLoadingToComplete(driver);
enterPassword(password);
Utils.waitForPageLoadingToComplete(driver);
clickOnLoginButton();
} catch(Exception e) {
e.printStackTrace();
}
}
=============================================================================================
Error Coming
[TestNG] Running:
C:\Users\Daffodil-255\AppData\Local\Temp\testng-eclipse--467741697\testng-customsuite.xml
Print app path E:\TodoistAutomation\Android_Todoist_Project\apkfile\Todoist_v12.8_apkpure.com.apk
Jul 25, 2018 11:57:52 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
email_id =tarun.dabbs#daffodilsw.com
projectName =123456
Jul 25, 2018 11:57:52 AM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown method' (405 expected)
FAILED CONFIGURATION: #AfterMethod closeApplication
org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:14.902Z'
System info: host: 'DAFFODILLAP-265', ip: '172.18.1.128', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_65'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: E:\TodoistAutomation\Androi..., appActivity: com.todoist.activity.HomeAc..., appPackage: com.todoist, appium-version: 1.8.1, databaseEnabled: false, desired: {app: E:\TodoistAutomation\Androi..., appActivity: com.todoist.activity.HomeAc..., appPackage: com.todoist, appium-version: 1.8.1, deviceName: Nexus5X1, platformName: android, platformVersion: 7.1.1}, deviceManufacturer: Google, deviceModel: Android SDK built for x86, deviceName: emulator-5554, deviceScreenSize: 1080x1920, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, platform: LINUX, platformName: Android, platformVersion: 7.1.1, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 7333c28b-2ec8-48b2-89c0-b04e2c90ec74
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:438)
at com.todoist.tests.VerifyProjectFromApp.closeApplication(VerifyProjectFromApp.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:703)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
FAILED: verifyCreatedProjectInApp
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/MethodInterceptor
at com.todoist.pages.LoginPage.<init>(LoginPage.java:22)
at com.todoist.tests.VerifyProjectFromApp.verifyCreatedProjectInApp(VerifyProjectFromApp.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 26 more
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter#19bb089b: 171 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter#35bbe5e8: 14 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter#6bdf28bb: 8 ms
[TestNG] Time taken by org.testng.reporters.jq.Main#1fbc7afb: 65 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2#129a8472: 15 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 11 ms
Issue happens due this:
ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor
to fix this you need to add cglib:cglib dependency:
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.7</version>
</dependency>
hope this helps,
Add both cglib and asm dependency in your project. This will solve your problem.
cglib-3.2.7.jar
asm-6.2.jar
Actually I have installed all latest versions. My firefox browser launches. But URL is not called.
Following are my System details.
OS: Ubuntu 14.04
Firefox Version: 56.0
Selenium Server: selenium-server-standalone-3.6.0
GeckoDriver: geckodriver-v0.19.0-linux64
Browser Launch Code
if(BrowserCode.equalsIgnoreCase("FF"))
{
System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir")+"/AllDrivers/geckodriver");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
}
I am getting following eror. Can anyone please help me in this.
[TestNG] Running:
/home/vishalpachpute/workspace/ER_CustomerCare/ERCC_Login.xml
/home/vishalpachpute/workspace/ER_CustomerCare
1507724942300 geckodriver INFO geckodriver 0.19.0
1507724942306 geckodriver INFO Listening on 127.0.0.1:3966
1507724942723 mozrunner::runner INFO Running command: "/usr/lib/firefox/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.qsoDFMATTikn"
1507724942948 addons.xpi WARN Error parsing extensions state: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [amIAddonManagerStartup.readStartupData]" nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: resource://gre/modules/addons/XPIProvider.jsm :: loadExtensionState :: line 1554" data: no] Stack trace: loadExtensionState()#resource://gre/modules/addons/XPIProvider.jsm:1554 < getInstallState()#resource://gre/modules/addons/XPIProvider.jsm:1589 < checkForChanges()#resource://gre/modules/addons/XPIProvider.jsm:3109 < startup()#resource://gre/modules/addons/XPIProvider.jsm:2188 < callProvider()#resource://gre/modules/AddonManager.jsm:269 < _startProvider()#resource://gre/modules/AddonManager.jsm:739 < startup()#resource://gre/modules/AddonManager.jsm:906 < startup()#resource://gre/modules/AddonManager.jsm:3090 < observe()#jar:file:///usr/lib/firefox/omni.ja!/components/addonManager.js:65
1507724943785 Marionette INFO Enabled via --marionette
(firefox:22169): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(firefox:22169): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
(firefox:22169): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(firefox:22169): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
1507724946494 Marionette INFO Listening on port 38903
1507725070118 Marionette WARN TLS certificate errors will be ignored for this session
1507725070153 Marionette DEBUG Register listener.js for window 2147483649
Oct 11, 2017 6:01:10 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
1507725070269 Marionette DEBUG Received DOM event "beforeunload" for "about:blank"
1507725160564 Marionette DEBUG Received DOM event "beforeunload" for "about:blank"
1507725160566 Marionette DEBUG Received DOM event "pagehide" for "about:blank"
1507725160567 Marionette DEBUG Received DOM event "unload" for "about:blank"
1507725160612 Marionette DEBUG Received DOM event "DOMContentLoaded" for "about:neterror?e=netTimeout&u=http%3A//localhost%3A8888/ercc/&c=UTF-8&f=regular&d=The%20server%20at%20localhost%20is%20taking%20too%20long%20to%20respond."
org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=netTimeout&u=http%3A//localhost%3A8888/ercc/&c=UTF-8&f=regular&d=The%20server%20at%20localhost%20is%20taking%20too%20long%20to%20respond.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
System info: host: 'vfrootThinkPadT450', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-30-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=/tmp/rust_mozprofile.qsoDFMATTikn, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, moz:headless=false, platform=LINUX, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=56.0, platformVersion=3.16.0-30-generic, moz:processID=22169, browserName=firefox, javascriptEnabled=true, platformName=LINUX}]
Session ID: 12542456-e71a-40f4-944d-c476840f3c99
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:310)
at com.vodafone.er.cc.test.integration.PlatformLayer.LaunchApplication.Execute(LaunchApplication.java:173)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.TestRunner.beforeRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:616)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
===============================================
ER
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
Attached my full LaunchApplication.java file for more details
package com.vodafone.er.cc.test.integration.PlatformLayer;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
//import java.sql.Date;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import atu.testng.reports.ATUReports;
import atu.testrecorder.ATUTestRecorder;
import atu.testrecorder.exceptions.ATUTestRecorderException;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
/*#Listeners({ ATUReportsListener.class, ConfigurationListener.class,
MethodListener.class })*/
public class LaunchApplication {
{
System.setProperty("atu.reporter.config", "./atu.properties");
}
public static WebDriver driver=null;
ATUTestRecorder recorder;
Date date;
#BeforeTest (alwaysRun = true)
#Parameters({"RunUsingSG","BrowserCode","URL","Title","Platform","Version"})
public void Execute(String RunUsingSG,String BrowserCode,String URL,String Title,String Platform,String Version) throws IOException, InterruptedException, ATUTestRecorderException
{
System.out.println(System.getProperty("user.dir"));
DesiredCapabilities dc=new DesiredCapabilities();
//This code is for recording. if you want to do recording, just uncomment the following code.
/*DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH-mm-ss");
Date date = new Date();
// For Recording the Execution using ATU Reporter.
recorder = new ATUTestRecorder("./ScriptVideos","TestVideo-" +dateFormat.format(date),false);
recorder.start();*/
// For IE 32 Bits
if(BrowserCode.equalsIgnoreCase("IE32"))
{
dc.setBrowserName("internet explorer");
dc.setVersion(Version);
if(RunUsingSG.equalsIgnoreCase("Y"))
{driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc);}
else
{
System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_32bit_OS.exe");
driver = new InternetExplorerDriver();
}
}
// For PhantomJS
if(BrowserCode.equalsIgnoreCase("PJS"))
{
dc.setJavascriptEnabled(true);
dc.setVersion(Version);
dc.setBrowserName("Phantom JS");
dc.setCapability("phantomjs.binary", "/AllDrivers/phantomjs");
driver = new PhantomJSDriver(dc);
}
//For IE 64 Bits
if(BrowserCode.equalsIgnoreCase("IE64"))
{
//System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_64bit_OS.exe");
System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_x64_2.41.0/IEDriverServer_V2.41_64bit.exe");
dc.setBrowserName("internet explorer");
dc.setVersion(Version);
if(RunUsingSG.equalsIgnoreCase("Y"))
{
driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc);
}
else
{
//System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_64bit_OS.exe");
System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_x64_2.41.0/IEDriverServer_V2.41_64bit.exe");
driver = new InternetExplorerDriver();}
}
/*//For Firefox
if(BrowserCode.equalsIgnoreCase("FF"))
{
FirefoxProfile firefoxProfile = new FirefoxProfile();
dc.setBrowserName("firefox");
//dc.setVersion(Version);
if(RunUsingSG.equalsIgnoreCase("Y"))
{
driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc);
}
else
{
driver=new FirefoxDriver();
}
}*/
//For Firefox GeckoDriver
if(BrowserCode.equalsIgnoreCase("FF"))
{
System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir")+"/AllDrivers/geckodriver");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver = new FirefoxDriver(capabilities);
driver.get("URL");
}
// For Chrome
if(BrowserCode.equalsIgnoreCase("CH"))
{
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
dc.setCapability("chrome.binary","./AllDrivers/chromedriver/");
dc.setCapability(ChromeOptions.CAPABILITY, options);
dc.setBrowserName("Google Chrome");
dc.setVersion(Version);
if(RunUsingSG.equalsIgnoreCase("Y"))
{
driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc);
}
else
{
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"/AllDrivers/chromedriver");
driver = new ChromeDriver(dc);
}
}
if(Platform.equalsIgnoreCase("WINDOWS"))
try
{
{dc.setPlatform(org.openqa.selenium.Platform.WINDOWS);}
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get(URL);
Thread.sleep(3000);
Assert.assertEquals(driver.getTitle(), Title);
driver.manage().window().maximize();
Thread.sleep(2000);
// ATU Reports
ATUReports.setWebDriver(LaunchApplication.driver);
ATUReports.indexPageDescription = "ER-CC Automation Scripts Results.";
}
catch (Exception e)
{
Reporter.log("Exception occured " +e.getMessage());
e.printStackTrace();
Assert.fail();
driver.quit();
}
}
#AfterTest
//#Parameters({"RunUsingSG","BrowserCode","URL","Title","Platform","Version"})
public void TearDown() throws MalformedURLException, ATUTestRecorderException
{
driver.close();
//driver.quit();
//recorder.stop();
}
}
This code dont have any URL
if(BrowserCode.equalsIgnoreCase("FF"))
{
System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir")+"/AllDrivers/geckodriver");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
driver.get("URL"); //add it
}
Need a help. I have the same test suite. I have run this test suite in IDEA on my local machine. And the tests are passed. Then I run this test suite in TeamCity. The tests are failed with the next stack trace:
======= Failed test run #1 ==========
org.openqa.selenium.ElementNotVisibleException: element not visible
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 18 milliseconds
Build info: version: 'unknown', revision: '31c43c8', time: '2016-08-02 21:57:56 -0700'
System info: host: 'build', ip: '175.35.15.235', os.name: 'Windows Server 2012 R2', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\TeamCity\buildAgent\temp\buildTmp\scoped_dir948_4499}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.71, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: e69e7517d0cc60ff138519603c9efe99
org.openqa.selenium.ElementNotVisibleException:
element not visible
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 18 milliseconds
Build info: version: 'unknown', revision: '31c43c8', time: '2016-08-02 21:57:56 -0700'
System info: host: 'build', ip: '175.35.15.235', os.name: 'Windows Server 2012 R2', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\TeamCity\buildAgent\temp\buildTmp\scoped_dir948_4499}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.71, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: e69e7517d0cc60ff138519603c9efe99
at com.automation.webdriver.testStoryReportsNavigation.policiesWithPremium(testStoryReportsNavigation.java:122)
122 line of code like this:
driver.findElement (By.xpath ( "// * [# id = \" 0 \ "]")) click ();
(No matter for xpath looking for, or id - in TeamCity the same result)
In what may be the cause of this error?
Tests are run with agent on the same machine that serves TeamCity.
There is a code:
package com.automation.webdriver;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.server.handler.CaptureScreenshot;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.ITestResult;
import org.testng.annotations.*;
import pageObjects.homePage;
import utility.Constant;
import utility.ExcelUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class testStoryReportsNavigation {
public WebDriver driver;
private int storyNumber;
private String storyDescription;
#Factory(dataProvider = "dataMethod", dataProviderClass = dataProvider.class)
public testStoryReportsNavigation(int storyNumber, String storyDescription) {
this.storyNumber = storyNumber;
this.storyDescription = storyDescription;
}
#BeforeMethod
public void beforeClass() throws Exception {
System.setProperty(Constant.chromeDriver,Constant.chromeDriverPath);
driver = new ChromeDriver();
ExcelUtils.setExcelFile(Constant.File_userData,"Users");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get(Constant.devUrl + Constant.loginPage);
WebDriverWait waitLoginPage = new WebDriverWait(driver, 10);
waitLoginPage.until(ExpectedConditions.titleIs("Log in Milliman"));
if (driver.findElements(By.className("glimpse-icon")).size()!=0) {
driver.get(Constant.devUrl + Constant.glimpseSettings);
driver.findElement(By.id("buttonTurnGlimpseOff")).click();
driver.getPageSource().contains("Glimpse cookie set 'Off'");
driver.get(Constant.devUrl + Constant.loginPage);
} else {
System.out.println("Glimpse disabled");
}
WebDriverWait waitLoginPageAgain = new WebDriverWait(driver, 10);
waitLoginPageAgain.until(ExpectedConditions.titleIs("Log in Milliman"));
WebElement eMail = driver.findElement(By.id("Email"));
eMail.sendKeys(ExcelUtils.getCellData(1, 1));
WebElement password = driver.findElement(By.id("Password"));
password.sendKeys(ExcelUtils.getCellData(1, 2));
password.submit();
//Check that Grid View appears after user login:
WebDriverWait wait = new WebDriverWait(driver, 3);
wait.until(ExpectedConditions.urlContains(Constant.gridView));
System.out.println("Login Successful");
//Navigate to Story
System.out.println("Navigating to " + Constant.devUrl + Constant.storyPage + storyNumber + "(" + storyDescription + ")");
driver.get(Constant.devUrl + Constant.storyPage + storyNumber);
WebDriverWait waitLogout = new WebDriverWait(driver, 20);
waitLogout.until(ExpectedConditions.elementToBeClickable(By.className("FiltersShortSummaryBlock")));
//Check that story loaded
driver.findElement(By.className("FiltersShortSummaryBlock")).click();
WebDriverWait waitUrButton = new WebDriverWait(driver, 20);
waitUrButton.until(ExpectedConditions.elementToBeClickable(By.id("UpdateResults")));
//Select Data Source value
driver.findElement(By.xpath("//*[#id=\"PanelGeneral\"]/table/tbody/tr[2]/td[1]/table/tbody/tr[1]/td[2]/button")).click();
WebDriverWait waitDataSource = new WebDriverWait(driver, 10);
waitDataSource.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[contains(text(), 'Market Basket')]")));
driver.findElement(By.xpath("//span[contains(text(), 'Market Basket')]")).click();
//Select Primary Carrier value
driver.findElement(By.xpath("//*[#id=\"PanelGeneral\"]/table/tbody/tr[2]/td[1]/table/tbody/tr[3]/td[2]/button")).click();
driver.findElement(By.xpath("/html/body/div[60]/ul/li[2]/label")).click();
//Select Secondary Carriers value
driver.findElement(By.xpath("//*[#id=\"PanelGeneral\"]/table/tbody/tr[2]/td[1]/table/tbody/tr[4]/td[2]/button")).click();
driver.findElement(By.xpath("/html/body/div[14]/div/ul/li[1]/a/span[2]")).click();
//Click Update Results button
WebDriverWait waitButton = new WebDriverWait(driver, 30);
waitButton.until(ExpectedConditions.elementToBeClickable(By.id("UpdateResults")));
WebElement updateResults = driver.findElement(By.id("UpdateResults"));
updateResults.click();
//Check that Results were updated
WebDriverWait waitUpdateResults = new WebDriverWait(driver, 30);
waitUpdateResults.until(ExpectedConditions.elementToBeClickable(By.id("storyUnsaved")));
}
#Test (priority = 11)
public void policiesWithPremium() throws Exception {
//Generate report #0 and check that it was generated
driver.findElement(By.xpath("//*[#id=\"0\"]")).click();
//Check that report #0 was generated
WebDriverWait waitReportZero = new WebDriverWait(driver, 120);
waitReportZero.until(ExpectedConditions.visibilityOfElementLocated(By.id("RiskWithPremiumForm")));
}
I am able to run my protractor tests against localhost, but when hitting my in-house test server, I can't get protractor to find elements on the page. The same issues occur with Protractor 1.3.1 and 1.4.0 with the latest Chrome and Firefox drivers.
...AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113
var template = new Error(this.message);
^
Process finished with exit code 1
So I've been trying to use the Element explorer to debug the issue, but it is giving me the following:
> list(by.css('#logindropdown'))
There was a webdriver error: UnknownError unknown error: Runtime.evaluate threw exception: TypeError: Cannot read property 'click' of null
(Session info: chrome=38.0.2125.111)
(Driver info: chromedriver=2.12.301325 (962dea43ddd90e7e4224a03fa3c36a421281abb7),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 28 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'NB2D1469', ip: '158.147.71.49', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_67'
Session ID: 85966371ff89f75af8cf7fb5d15f6f23
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=C:\Users\mprent99\AppData\Local\Temp\scoped_dir6488_12276}, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=38.0
.2125.111, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
Simple things like list(by.css('body')) also give the same exception above. Using by.id give the same results, list(by.id('logindropdown'))
Commands that have no results (when they should) seem to avoid the exceptions:
> list(by.css('a .caret'))
[ '' ]
> list(by.css('.caret'))
[ '' ]
In the webdriver-manager terminal, I am seeing the following:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.executeAsyncScript(RemoteWebDriver.java:526)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
at com.sun.proxy.$Proxy1.executeAsyncScript(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.executeAsyncScript(EventFiringWebDriver.java:225)
at org.openqa.selenium.remote.server.handler.ExecuteAsyncScript.call(ExecuteAsyncScript.java:55)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:168)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
and
17:05:00.256 INFO - Executing: [execute async script: try { return (function (rootSelector, callback) {
var el = document.querySelector(rootSelector);
try {
if (angular.getTestability) {
angular.getTestability(el).whenStable(callback);
} else {
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}
} catch (e) {
callback(e);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body]])
17:05:00.562 WARN - Exception thrown
org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: TypeError: Cannot read property 'click' of null
Versions in use:
protractor --version
Version 1.4.0 or Version 1.3.1
node --version
v0.10.30
webdriver-manager status
selenium standalone is up to date
chromedriver is up to date
IEDriver is not present
These same things work just fine in Chrome DevTools:
('.caret')
[<b class="caret"></b>]
$('a .caret')
[<b class="caret"></b>]
$('#logindropdown')
[<li id="logindropdown" class="dropdown ng-scope">…</li>]
$('body')
[<body class="vertical-grow">…</body>]
Here is the onPrepare where the failure appears to be happening:
onPrepare: function() {
var username = element(by.model('login.userName'));
var password = element(by.model('login.password'));
browser.driver.get(env.baseUrl);
browser.driver.findElement(by.css('a .caret')).click();
username.sendKeys('user#company.com');
password.sendKeys('password');
browser.driver.findElement(by.css('.btn-primary')).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 index.html.
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return (/dashboards/).test(url);
});
}, 5000);
}
Here is the rest of the conf.js:
/*global browser,element,by */
var env = require('./env.js');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'loginTest.js'
],
suites: {
//smoke: 'spec/smoketests/*.js',
//full: 'spec/*.js'
},
directConnect: false,
multiCapabilities: [
// {browserName: 'firefox'}
{browserName: 'chrome'}
],
maxSessions: -1,
framework: 'jasmine',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
// If true, display spec names.
isVerbose: false,
// If true, print colors to the terminal.
showColors: true,
// If true, include stack traces in failures.
includeStackTrace: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 360000
},
// Selector for the element housing the angular app - this defaults to
// body, but is necessary if ng-app is on a descendant of <body>
rootElement: 'html'
};
How do I debug this farther and get to the root of this issue?
I have the following tests, which run fine when I run them locally and on sauce (at least most of the time) using firefox and chrome.
ptor = protractor.getInstance();
baseUrl = protractor.getInstance().params.sBaseUrl;
aRequiredTextFieldsKeys = [
'sFirstName',
'sLastName',
'sStreet',
'sZip',
'sCity'
];
describe('form', function ()
{
var sFormUrl = baseUrl + '#/form';
beforeEach(function ()
{
ptor.get(sFormUrl);
});
describe('wholeForm', function ()
{
it('fully filled form => required fields have correct class && submit leads to other route', function ()
{
function checkRequiredClass(el)
{
expect(el.getAttribute('class')).toContain('ng-valid-required');
}
// requried text-fields
for (var i = 0; i < aRequiredTextFieldsKeys.length; i++) {
var el = element(by.model('oFormData.' + aRequiredTextFieldsKeys[i]));
el.sendKeys('a');
checkRequiredClass(el);
}
// email
var elEmail = element(by.model('oFormData.sEmail'));
elEmail.sendKeys('jo#jo.de');
checkRequiredClass(el);
// birthday
var elBirthday = element(by.model('oFormData.oBirthday'));
elBirthday.sendKeys('1.1.1995');
checkRequiredClass(el);
// checkboxes
var elCheck1 = element(by.model('oFormData.bAgb'));
elCheck1.click();
checkRequiredClass(elCheck1);
var elCheck2 = element(by.model('oFormData.bPrivatePolicy'));
elCheck2.click();
checkRequiredClass(elCheck2);
// hack upload bon
ptor.executeScript(function ()
{
var scope = $('#application-form-id').scope();
scope.oFormData.bBonUploaded = true;
});
// submit form
element(by.className('btn-submit')).click();
ptor.getCurrentUrl()
.then(function (url)
{
expect(url).toNotBe(sFormUrl);
});
});
});
But when I launch internet explorer or safari, I get all sorts of errors, while the page works fine when tested manually. For IE I get:
Message:
UnknownError: JavaScript error (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 97
milliseconds Build info: version: '2.30.0', revision: 'dc1ef9c', time:
'2013-02-19 00:15:27' System info: os.name: 'Windows Server 2008 R2',
os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35' Session
ID: 42b30348-8598-4edb-923e-a7019ced6eb0 Driver info:
org.openqa.selenium.ie.InternetExplorerDriver Capabilities
[{platform=WINDOWS, elementScrollBehavior=0, javascriptEnabled=true,
enablePersistentHover=true, ignoreZoomSetting=false,
browserName=internet explorer, enableElementCacheCleanup=true,
unexpectedAlertBehaviour=dismiss, version=10,
cssSelectorsEnabled=true, ignoreProtectedModeSettings=false,
requireWindowFocus=false, allowAsynchronousJavaScript=false,
handlesAlerts=true, initialBrowserUrl=, nativeEvents=true,
takesScreenshot=true}]
Error: Error while waiting for Protractor to sync with the page: {"stack":"TypeError:
Unable to get property 'get' of undefined or null reference\n at Anonymous function (Unknown
script code:25:5)\n at Anonymous function (Unknown script code:21:14)\n at Anonymous
function (Unknown script code:21:2)","description":"Unable to get property 'get' of undefined
or null reference","number":-2146823281}
And for Safari:
UnknownError: Detected a page unload event; script execution does not work across page loads. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 384 milliseconds
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:32:38'
System info: os.name: 'Windows Server 2008 R2', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35'
Session ID: null
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true, cssSelectorsEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=5.1.7}]
I'm confsued about the reasons. I tried simpler tests with the same results, I tried local and remote urls and I tried all sorts of delays like waitForAngular, wait and ptor ignoreAsynch = true. None of them lead to the desired outcome. Any suggestions?
My protractor config file:
// A reference configuration file.
exports.config = {
seleniumServerJar: null,
seleniumPort: null,
chromeOnly: false,
// Additional command line options to pass to selenium. For example,
// if you need to change the browser timeout, use
// seleniumArgs: ['-browserTimeout=60'],
seleniumArgs: [],
sauceUser: 'saucesuer',
sauceKey: 'key',
allScriptsTimeout: 120000,
specs: [
'test/e2e/**/*.js',
],
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
// https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path':'node_modules/phantomjs/bin/phantomjs'
},
// Selector for the element housing the angular app - this defaults to
// body, but is necessary if ng-app is on a descendant of <body>
rootElement: 'body',
onPrepare: function ()
{
// driver.manage().timeouts().setScriptTimeout(60000);
},
params: {
sBaseUrl: 'https://dev.com/'
},
baseUrl: 'http://localhost:8000',
framework: 'jasmine',
// ----- Options to be passed to minijasminenode -----
//
// See the full list at https://github.com/juliemr/minijasminenode
jasmineNodeOpts: {
// onComplete will be called just before the driver quits.
onComplete: null,
// If true, display spec names.
isVerbose: true,
// If true, print colors to the terminal.
showColors: true,
// If true, include stack traces in failures.
includeStackTrace: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 120000
}
};
WHile it doesnt seem to matter, I use grunt-protractor runner to run multiple instances sequentially.
chrome: {
options: {
args: {
browser: 'chrome',
"idle-timeout": 120
}
}
},
firefox: {
options: {
args: {
browser: 'firefox'
}
}
},
ie9: {
options: {
args: {
browser: 'internet explorer',
version: '9',
"idle-timeout": 120
}
}
},
ie10: {
options: {
args: {
browser: 'internet explorer',
version: '10'
}
}
},
safari7: {
options: {
args: {
browser: 'safari',
version: '7'
}
}
},
safari6: {
options: {
args: {
browser: 'safari',
version: '6'
}
}
},
safari5: {
options: {
args: {
browser: 'safari',
version: '5'
}
}
}
}
grunt.registerTask('e2eall', [
'protractor:ie9',
'protractor:ie10',
'protractor:safari5',
'protractor:safari6',
'protractor:safari7',
'protractor:firefox',
'protractor:chrome'
]);
Hugo,
This is an issue with certain test configurations that was partially solved in Protractor 0.17 and more definitively solved in 0.18. I would recommend updating your protractor to latest (0.18.1 at the time of this post) and seeing if that solves your issue.
Relevant changelog entries:
v0.18
(10aec0f) fix(pageload): increase wait timeout
The 300 ms wait caused problems when testing IE on Sauce Labs. It seems way too short. "browser.get()" invariably timed out. Increasing it solved our problem.
v0.17
(a0bd84b) fix(pageload): add a wait during protractor.get() to solve unload issues
Some systems would not wait for the browser unload event to finish before beginning the asynchronous script execution.
Closes #406. Closes #85.
Hope that helps!