Minium - Element is not attached to the page document - javascript

I found a strange behaviour at Minim Developer; when i run the following code in the console:
$(".form-group").has($(".control-label").withText("Description"))
.find(".cke_wysiwyg_frame").frames().find(".cke_editable").fill("Minium Test")
Minium is able to fill the field "Description"
But when I try to run the same code at the Step Definition, I have the following error:
org.mozilla.javascript.WrappedException: Wrapped
org.openqa.selenium.StaleElementReferenceException: stale element
reference: element is not attached to the page document (Session
info: chrome=68.0.3440.84) (Driver info: chromedriver=2.40.565498
(ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT
10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For
documentation on this error, please visit:
http://seleniumhq.org/exceptions/stale_element_reference.html Build
info: version: '3.8.1', revision: '6e95a6684b', time:
'2017-12-01T18:33:54.468Z' System info: host: '47ZZQC2', ip:
'169.254.70.131', os.name: 'Windows 10', os.arch: 'amd64', os.version:
'10.0', java.version: '1.8.0_172' Driver info:
org.openqa.selenium.remote.RemoteWebDriver Capabilities
{acceptInsecureCerts: false, acceptSslCerts: false,
applicationCacheEnabled: false, browserConnectionEnabled: false,
browserName: chrome, chrome: {chromedriverVersion: 2.40.565498
(ea082db3280dd6..., userDataDir: C:\Users\~1.SIL\AppDat...},
cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts:
true, hasTouchScreen: false, javascriptEnabled: true,
locationContextEnabled: true, mobileEmulationEnabled: false,
nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy:
normal, platform: XP, platformName: XP, rotatable: false,
setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true,
unexpectedAlertBehaviour: , unhandledPromptBehavior: , version:
68.0.3440.84, webStorageEnabled: true} Session ID: 103c08b587995e088faa269fbb46a4fd
(/minium/cucumber/internal/dsl.js#88(eval)#1) at
modules/forms.js:136 at modules/forms.js:175 at
modules/forms.js:204 at steps/General/steps.js:95
at ?.
When I fill the fields: features/Directory/Groups/groups.feature:48
Any ideias to solve this issue?

It seems an issue related to the use of interaction listener.
Are you adding any interaction listener to the browser configuration at world.js like this?
browser.configure()
.defaultTimeout(5, timeUnits.SECONDS)
.defaultInterval(500, timeUnits.MILLISECONDS)
.interactionListeners()
.add(minium.interactionListeners.onStaleElementReference().thenRetry())
.add(...)
...
.done();
If so, please move all the interaction Listeners to the Base Expression. For exmple:
base = $(":root")
.unless($(".modal").withCss("display", "block")).add(".modal-body")
.with(minium.interactionListeners.onStaleElementReference().thenRetry())
.with(...)
...
And run your code without the base expression, to avoid the call of interaction listener.

Related

Getting "ReferenceError: browser is not defined" in Appium framework for tvOS - how to define the browser?

I have a question about the use of an "expect().toExist() command (part of the "expect-webdriverio" package). I am attempting to use it in an appium test suite run on the mocha framework - we are testing an application on tvOS (not on any web browser) and I am getting the following error:
ReferenceError: browser is not defined
This is happening in a framework in which the "browser" is actually the "client". We use the word "client" because we are not testing anything web-based. So, this is the test script:
await client.pause(5000); //wait for app install and loading screen
const thisButton = await browser.$("~CONTINUE");
//console.log(client.capabilities);
console.log(thisButton);//this is logged in detail
await expect(thisButton).toExist();//this is where we get the error
await thisButton.click();//this works perfectly once we get to it.
await client.pause(10000);
... and here's what we see when I tell it to log thisButton:
Element {
sessionId: '57f34ce7-968c-47da-b2f3-42cea8e31090',
elementId: '0F000000-0000-0000-4C58-010000000000',
'element-6066-11e4-a52e-4f735466cecf': '0F000000-0000-0000-4C58-010000000000',
selector: '~CONTINUE',
parent: Browser {
sessionId: '57f34ce7-968c-47da-b2f3-42cea8e31090',
capabilities: {
webStorageEnabled: false,
locationContextEnabled: false,
browserName: '',
platform: 'MAC',
javascriptEnabled: true,
databaseEnabled: false,
takesScreenshot: true,
networkConnectionEnabled: false,
platformName: 'tvOS',
automationName: 'XCUITest',
deviceName: 'Apple TV',
platformVersion: '15.4',
app: <not listed - path is completely internal to the computer>,
udid: 'D5A91802-8E82-47FF-9408-68A39FA606FC'
},
addCommand: [Function (anonymous)],
overwriteCommand: [Function (anonymous)],
addLocatorStrategy: [Function (anonymous)]
},
emit: [Function: bound ],
isReactElement: false,
addCommand: [Function (anonymous)],
overwriteCommand: [Function (anonymous)]
}
The capabilities used are contained in the "caps.js" file - contents are as follows:
const tvosCaps = {
platformName: "tvOS",
automationName: "XCUITest",
deviceName: process.env.IOS_DEVICE_NAME || "Apple TV",
platformVersion: process.env.IOS_PLATFORM_VERSION || "15.4",
app: undefined, //to be defined in test file
};
const serverConfig = {
path: "/wd/hub",
host: process.env.APPIUM_HOST || "localhost",
port: process.env.APPIUM_PORT || 4723,
logLevel: "info",
};
const tvosOptions = Object.assign(
{
capabilities: tvosCaps,
},
serverConfig
);
module.exports = {
tvosOptions,
};
There is a wdio.conf.js file, but it has value "chrome" for browserName, and we're not using chrome at all for this. I have it set up to use appium as a service - I'm not sure how to include it in the configuration. Maybe through package.json?
Any idea as to how to get past this ReferenceError?

How to include javascript library in grunt

I am working on an existing Ionic project. I am trying to include the Ionic's push notification feature within this project. When I try to run grunt command I get following error
Running "jsbeautifier:files" (jsbeautifier) task
Beautified 53 files, changed 0 files...OK
Running "jshint:files" (jshint) task
./www/js/app.js
18 | var push = new Ionic.Push({
^ 'Ionic' is not defined.
So looks like the ionic JS file under lib/ionic-platform-web-client/dist/ionic.io.bundle.min.js is not getting loaded in grunt. How to fix this? I am new to grunt and ionic, so please help me out. I didn't find any solution in other similar questions.
BTW, the app works fine in browser.
gruntfile.js jshint
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
strict: false,
globalstrict: false,
node: true,
undef: true,
globals: {
angular: true,
cordova: true,
app: true,
StatusBar: true,
CameraPopoverOptions: true,
ionic: true,
Camera: true
},
},
files: {
src: ["*.js", "./www/js/*.js", "./www/components/**/*.js", "!*.min.js", "!./www/**/*.min.js", "!./www/**/**/*.min.js"]
}
},
globals: {
angular: true,
cordova: true,
app: true,
StatusBar: true,
CameraPopoverOptions: true,
Ionic: true,
Camera: true
}
Ionic should have capital I.

Protractor - Internet explorer driver doesn't run with selenium webdriver

I've tried any solution on google results about this issue, but nothing is help.
Please help me to figure this out,
thanks!
Protractor conf:
exports.config = {
chromeDriver: 'npm/node_modules/protractor/selenium/chromedriver',
chromeOnly: false,
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['c:\\automation\\tests\\testCases\\newApp\\screenshotsTesting.js'],
multiCapabilities: [{
'browserName': 'firefox',
'cli': {
'args': ['webdriver.firefox.useExisting=default']
// 'args': ['webdriver.firefox.useExisting=default', '-jsconsole', '-jsdebugger']
}},
{
'browserName': 'chrome',
'chromeOptions': {
args: ['--test-type','--memory-metrics','--console','--crash-on-failure']
// '--load-extension=' + 'C:\\Users\\idan\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Extensions\\idgpnmonknjnojddfkpgkljpfnnfcklj\\1.2.4_0'
}
}},
{
'browserName': 'internet explorer'
'platform': 'ANY',
'version': '11'
}],
// maxSessions: 1,
// rootElement: '.main',
framework: "jasmine",
allScriptsTimeout: 60000,
getPageTimeout: 60000,
....
IE11 tools - all zone level are the same and enabled:
Selenium WD launching:
java -Dwebdriver.ie.driver=C:\automation\npm\node_modules\selenium-standalone\.selenium\iedriver\IEDriverServer.exe -jar C:\automation\npm\node_modules\selenium-standalone\.selenium\selenium-server\2.45.0-server.jar
Protractor launching:
c:\automation\tests\protractor-conf.js --browser="internet explorer" --seleniumAddress=http://localhost:4444/wd/hub
Error from Selenium webdriver console:
Caused by: org.openqa.selenium.remote.SessionNotFoundException: Unexpected error
launching Internet Explorer. Protected Mode settings are not the same for all z
ones. Enable Protected Mode must be set to the same value (enabled or disabled)
for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.04 seconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'vCitaQA', ip: '192.168.152.1', os.name: 'Windows 8.1', os.ar
ch: 'amd64', os.version: '6.3', java.version: '1.8.0_25'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
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:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriv
er.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriv
er.java:225)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDri
ver.java:182)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorer
Driver.java:174)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorer
Driver.java:150)
... 14 more
09:19:13.656 WARN - Exception: Unexpected error launching Internet Explorer. Pro
tected Mode settings are not the same for all zones. Enable Protected Mode must
be set to the same value (enabled or disabled) for all zones. (WARNING: The serv
er did not provide any stacktrace information)
Command duration or timeout: 1.04 seconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'vCitaQA', ip: '192.168.152.1', os.name: 'Windows 8.1', os.ar
ch: 'amd64', os.version: '6.3', java.version: '1.8.0_25'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver

Protractor not testing, WebDriver fails after 1 minute

I'm really new to Protractor and everything NodeJS, and i'm trying to get started using Protractor with AngularJS.
I used the Yeoman generator-gulp-angular to generate a project and all is well, but when i try to protractor protractor.conf.js (i've installed Java and Chromium) the following happens:
vagrant#server:/var/www/html/project/$ protractor protractor.conf.js
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.103.173:38573/wd/hub
It hangs here for 1 minute, and then spurts out the following:
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
var template = new Error(this.message);
^
UnknownError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 3.13.0-24-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.69 seconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'server', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_75'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at new bot.Error (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113:18)
at Object.bot.response.checkResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:152:24
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
at notifyAll (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:442:7)
at resolve (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:420:7)
at fulfill (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:535:5)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:149:22)
at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:123:30)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:294:22)
at DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:180:37)
at /usr/local/lib/node_modules/protractor/lib/runner.js:257:21
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
[launcher] Process exited with error code 1
And exits.
This is my protractory.conf.js:
'use strict';
var paths = require('./.yo-rc.json')['generator-gulp-angular'].props.paths;
exports.config = {
node_modules/protractor/config.json
capabilities: {
'browserName': 'chrome'
},
specs: [paths.e2e + '/**/*.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
I hope someone can help me out!
EDIT
I've added my (single) test code to provide more insight:
'use strict';
describe('The main view', function () {
var page;
beforeEach(function () {
browser.get('http://localhost:3000/index.html');
page = require('./main.po');
});
it('Should display the homepage', function() {
expect(page.header.getText()).toContain("Home");
});
});
And my Page Object file:
'use strict';
var MainPage = function() {
this.header = element(by.tagName('header'));
};
module.exports = new MainPage();

Grunt: Running tasks after "jasmine_node"

I'm implementing my own XML/HTML-reporting tool for test-automation using grunt, jasmine_node and some other tools. Unfortunately I need to run some tasks right after jasmine_node --> in fact I only use jasmine_node for creating junit xml reports :D
The problem is: When jasmine is done with testing, it is exiting the task chain (whether I use forceexit or not). But I need the following tasks to be executed.
See below my config:
jasmine_node: {
options: {
forceExit: true,
match: '.',
matchall: false,
extensions: 'js',
specNameMatcher: 'spec',
includeStackTrace: false,
jUnit: {
report: true,
savePath : "test-automation/test-xml/",
useDotNotation: true,
consolidate: true
}
},
all: ['test-automation/test-specs/']
},
And here comes the chain:
grunt.registerTask('test', ['jasmine_node', 'junit_xml_merge', 'open', 'connect']);
What am I doing wrong here?

Categories

Resources