WebdriverIO w/ Appium BDD Step Definition file not finding Page Object error Identifier expected.ts(1003) - testing

I am trying to perform a simple test in with appium with webdriverIO in JS. When I try to access the methods from the page objects file into the step definition file I'm getting the following error: Identifier expected.ts(1003)
The feature file is ok
here is a my feature file
Feature: Onboarding Carousel
Scenario: As a brand new user I can travel through the onboarding carousel to view the Sign up Screen
Given I can tap the first next button for the My Garden app
And I tap the second next button on the second page of the onbarding carousel
When I can view the lets get started button on the final page of the on-boarding carousel
Then I am taken the new customer sign up screen
This is my Page Objects page
class carouselPages extends Page {
get nextButton1 () {
return $('~Next');
}
get nextButton2 () {
return $('~Next');
}
get getStartedButton () {
return $("~Let's get started");
}
async tapkOnNextButton1(){
await this.nextButton1
}
async tapOnNextButton2(){
await this.nextButton2
}
async tapLetsGetStartedButton(){
await this.getStartedButton
}
}
exports = new carouselPages();
Screen shot of terminal

Related

Clicking on button in iframe in Cypress

Ran into the issue, where the test code should click the button Process in the iframe. Used npm i cypress-iframe lib, but came up to nothing. Cypress could not find the button.
Tried cy.iframe('[class="resp-iframe"]').find('resp-iframe[id="submit"]')
HTML of the problem
Tried the other ways to click on iframe button:
cy.get('iframe[class="resp-iframe"]').then($element => {
const $body = $element.contents().find('body')
cy.wrap($body).find('resp-iframe[class="btn btn-block btn-primary"]').eq(0).click();
})
also
cy.get('[class="resp-iframe"]').then($element => {
const $body = $element.contents().find('body')
let stripe = cy.wrap($body)
stripe.find('[class="resp-iframe"]').click(150,150)
})
and
cy.iframe('#resp-iframe').find('[name="submitButton"]')
Error
Error 2
Updated FYI:
The first part of code - clicking the Google button in bottom-right:
const getIframeBody = () => {
// get the iframe > document > body
// and retry until the body element is not empty
return cy
.get('[id="popup-contentIframe"]')
.its('0.contentDocument.body')
// wraps "body" DOM element to allow
// chaining more Cypress commands, like ".find(...)"
// https://on.cypress.io/wrap
.then(cy.wrap)
}
getIframeBody().find('[id="payWithout3DS"]').click()
Then, waiting for secure payment preloader to finish up:
cy.wait(20000)
Then, trying to catch the Process button by suggestions:
cy.iframe('[name="AcsFrame"]').find('#submit').click()
or
cy.iframe('[class="resp-iframe"]').find('[id="submit"]')
whole code part looks:
const getIframeBody = () => {
// get the iframe > document > body
// and retry until the body element is not empty
return cy
.get('[id="popup-contentIframe"]')
.its('0.contentDocument.body')
// wraps "body" DOM element to allow
// chaining more Cypress commands, like ".find(...)"
// https://on.cypress.io/wrap
.then(cy.wrap)
}
getIframeBody().find('[id="payWithout3DS"]').click()
cy.wait(20000)
cy.iframe('[name="AcsFrame"]').find('#submit').click()
But still, getting:
Maybe anyone had something like that?
Thanks.
How about you try this:
cy.iframe('[name="AcsFrame"]').find('#submit').click()
You don't need to repeat the resp-iframe inside the .find().
The selector .find('resp-iframe[id="submit"]') means look for HTML like this: <resp-iframe id="submit"> but the element you want is <input id="submit">.
Everything else looks ok
cy.iframe('[class="resp-iframe"]').find('[id="submit"]')

how to show agreement Page just one time in ionic 4

I have a problem when working on app.I just want to create agreement page,which will show just one time when the app load first time. After that the page will never show. but in my app that page always showing when the app loaded.Please help me
You could set a boolean variable in storage when the agreement is first displayed, then you check if this variable has been set before showing the agreement.
For example:
import { Storage } from '#ionic/storage';
constructor() {
this.storage.get('agreement_displayed').then(val => {
if (!val) {
this.displayAgreement();
this.storage.set('agreement_displayed', true);
}
});
}

Unable to find element and send keys

So just a brief overview, I'm unable to send keys to a edit text field for android. I've successfully sent keys to this element via browser but in order to test the mobile application fully, I'd like to run e2e tests on a device using Appium.
I've successfully got Appium to click button elements but am having a hard time getting it to send keys to an edit field element.
Am I able to find elements by model when testing with android as I have set in my forgot-pin-page.js?
pin-reset-page.js
var pinResetPage = function() {
describe('The Reset Pin Flow', function () {
forgotPinPage = forgotPinPageBuilder.getForgotPinPage(),
describe('The Forgot Pin Page', function () {
it('should allow the user to enter their MSISDN and continue',
function () {
forgotPinPage.enterMsisdn('123123123');
forgotPinPage.doForgotPin();
expect(securityPage.isOnSecurityPage()).toBe(true);
});
});
}
forgot-pin-page.js
'use strict';
var ForgotPin = function () {
var forgotPinPageContent = element(by.id('forgot')),
msisdnInput = element(by.model('data.msisdn')),
return {
enterMsisdn: function (msisdn) {
return msisdnInput.sendKeys(msisdn);
}
};
module.exports.getForgotPinPage = function () {
return new ForgotPin();
};
The error i'm getting is
? should allow the user to enter their MSISDN and continue
- Error: Timeout - Async callback was not invoked within timeout spe
cified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Not sure if this is the correct solution but it worked for me. I downgraded jasmine2 to jasmine and that seemed to resolved the async timeouts I was having.

protractor iframe inside an iframe inside an iframe

I'm trying to get to controls inside a frame that is located inside a frame that is located inside another frame.
The last (deepest) frame is used only for login - that I manage to do.
The problem is that after the login I basically need to return to the upper frame and click a button. For some reason I keep getting the error:
NoSuchElementError: no such element
BTW, all the code in the frames is non-angular.
This is my code for the test:
it('Should get to drive sample app', function () {
login.get();
login.clickLogin();
browser.ignoreSynchronization = false;
login.goToUsecases(); //getting to the page
$('[href="/developers/api/1542"]').click();
browser.sleep(5000);
//iframe issue starts here
browser.switchTo().frame(0);
browser.ignoreSynchronization = true;
browser.switchTo().frame(0);
browser.switchTo().frame(0);
browser.driver.findElement(by.id('userName_str')).sendKeys("username");
browser.driver.findElement(by.id('password')).sendKeys("password");
browser.driver.findElement(by.name('submit')).click();
// login succeeded
browser.sleep(10000);
browser.driver.switchTo().defaultContent();
browser.driver.findElement(by.id('home')).click();
browser.sleep(10000);
});
The problem is that after the login I basically need to return to the upper frame and click a button.
From what I see in your code, you are switching to the default content, but, as you said, the button is inside the upper iframe, switch to it:
browser.driver.switchTo().defaultContent();
browser.switchTo().frame(0);
browser.driver.findElement(by.id('home')).click();
You can try this may be this helps you.. As this works for me for handling different windows.
browser.getAllWindowHandles().then(function (handles) {
newWindowHandle = handles[1];
browser.ignoreSynchronization = true;
browser.switchTo().window(newWindowHandle).then(function () {
browser.sleep(500).then(function () {
browser.ignoreSynchronization = true;
browser.driver.findElement(by.id('userName_str')).sendKeys("username");
browser.driver.findElement(by.id('password')).sendKeys("password");
browser.driver.findElement(by.name('submit')).click();
//login succeeded
});
//to close the current window
browser.driver.close().then(function () {
//to switch to the previous window
browser.switchTo().window(handles[0])
browser.driver.findElement(by.id('home')).click()
browser.sleep(10000);
});
});
});
Instead of ::browser.switchTo().frame(0);
try giving the locate of the iframe where you want to switch too.. that might help.
// Switch to iframe context in order to see inside iframe
browser.switchTo().frame(element(by.tagName('iframe')));

Titanium TabGroup: How to close window and then display the tab Group?

I have following flow of app :
First screen is Login screen and if Login gets success the tab-group opens.
here is code :
app.js
var win = Titanium.UI.createWindow
({
title:'User Login',
url:'Login.js',
tabBarHidden:true,
backgroundColor:'gray',
navBarHidden:false
});
win.open();
Login.js
var win = Ti.UI.currentWindow;
// some UI controls
loginBtn.addEventListener('click', function(e)
{
//calling web service
if(isSuccess == 1)
{
var tabGroup = Titanium.UI.createTabGroup();
// code to create Tab
tabGroup.open();
}
}
Now if I hide the currentWindow (win) every thing works fine But Login view is get displayed in background of all the time !!! So I want to close Login window and then open the tab group. So I tried :
win.close();
tabGroup.open();
But doesn't work application gets crashed.
So, How to close window and then display the tab Group ???
Thanks....
Solved !!! As slash197 has suggested in Login.js I was trying to close win which was the root window. So I used a dummy window inside the Login.js and close it and the open tabGroup . Like :
Login.js
var win = Ti.UI.currentWindow;
var loginView = Ti.UI.createWindow
({
backgroundColor:'transparent'
});
And added all the UI component into the loginView instead of win.
Then for Android
loginView.open();
And for iPhone
loginView.open();
win.add(loginView);
After success :-
loginBtn.addEventListener('click', function(e)
{
//calling web service
if(isSuccess == 1)
{
var tabGroup = Titanium.UI.createTabGroup();
// code to create Tab
//for Android
loginView.close();
//for iPhone
win.remove(loginView);
tabGroup.open();
}
}
Note:- Not sure that it is best approach. But it works for me.
If that window is the first than it's the root element and can't be closed. You could try removing all of it's children and set it's background to transparent then open your tabGroup.