Element not found error is coming
rohitkris opened this issue · comments
Hello Team,
Today when i tried to run protractor , it error out for "element not found". But the same script worked till yesterday. Not sure abt reason for it. Please help me.
Package json
{
"name": "roundglassapp",
"version": "0.0.1",
"description": "",
"main": "index.js",
"author": "RK",
"license": "ISC",
"scripts": {
"tsc": "tsc",
"pretest": "npm run tsc",
"posttest": "allure serve",
"test": "protractor jsfiles/conf/conf.js",
"protractor": "./node_modules/.bin/protractor/built/cli.js",
"webdriver-update": "./node_modules/.bin/webdriver-manager update",
"debug": "node --inspect-brk ./node_modules/.bin/protractor asyncAwait/conf.js"
},
"dependencies": {
"@cucumber/cucumber": "~7.3.1",
"@types/jasmine": "~3.8.2",
"@types/jasminewd2": "~2.0.10",
"@types/node": "~16.6.0",
"allure-js-commons": "~1.3.1",
"jasmine": "~3.8.0",
"jasmine-allure-reporter": "~1.0.2",
"protractor": "~7.0.0",
"protractor-cucumber-framework": "~8.2.3",
"ts-node": "~10.2.0",
"typescript": "~4.3.5",
"allure-commandline": "~2.3.5",
"protractor-beautiful-reporter": "~1.3.6"
}
}
Class Code snippet -
export class objSignInBefore {
signin_button;username;btnlogin;pwd;out;closesigninpop:ElementFinder;
constructor(){
// Loading elements by default
this.signin_button = element(by.xpath('//span[contains(text(),\'Login\')]'));
this.username = element(by.id('mat-input-0'));
this.pwd = element((by.id('mat-input-1')));
this.btnlogin = element(by.id('gtm-signin-email'));
}
// Functions Declaration
fnVerifySiginIn(uid:string,pass:string) {
this.signin_button.click();
browser.wait(this.btnlogin.isPresent(), 4000);
this.username.clear();
this.username.sendKeys(uid);
this.pwd.clear();
this.pwd.sendKeys(pass)
this.btnlogin.click().then(()=>{
browser.sleep(3000);
})
}
}
// Test File Snippet
import {browser, by} from "protractor";
import {base} from "../data/base";
import {objSignInAfter} from "../pageobjects/objSignInAfter";
import {objSignInBefore} from "../pageobjects/objSignInBefore";
import {objGeneric} from "../pageobjects/objGeneric";
let signinobj = new objSignInBefore();
let signinobj2 = new objSignInAfter();
let gen = new objGeneric();
describe("Running test cases for sign in validation",()=>{
beforeAll(() => {
console.log("Execution started for Sign In test cases");
});
afterAll(() => {
console.log("Execution completed for Sign In test cases");
});
it("Verifying invalid sign in - Case 1",()=>{
signinobj.fnVerifySiginIn(base.INVALIDUSERNAMET1, base.VALIDPASSWORD);
// await expect(element(by.id(base.BTN_LOGIN)).isPresent()).toBe(false);
expect(signinobj.btnlogin.isPresent()).toBe(true,"Test Case Failed");
// expect(signinobj.fnClosingModal().isPresent()).toBe(true,"Test Case Failed");
browser.refresh().then(()=>{
browser.sleep(3000);
console.log("Verifying invalid sign in - Case 1 - Verified Successfully")
})
}
)
it("Verifying invalid sign in - Case 2",()=>{
signinobj.fnVerifySiginIn(base.VALIDUSERNAME, base.INVALIDPASSWORDT1);
// await expect(element(by.id(base.BTN_LOGIN)).isPresent()).toBe(false);
expect(signinobj.btnlogin.isPresent()).toBe(true, "Test Case Failed");
browser.refresh().then(()=>{
browser.sleep(3000);
console.log("Verifying invalid sign in - Case 2 - Verified Successfully")
})
}
)
it("Verifying valid sign in",()=>{
signinobj.fnVerifySiginIn(base.VALIDUSERNAME, base.VALIDPASSWORD);
// await expect(element(by.id(base.BTN_LOGIN)).isPresent()).toBe(false);
expect(signinobj.btnlogin.isPresent()).not.toBe(true, "Test Case Failed");
expect(signinobj2.avatar.isPresent()).toBe(true, "Test Case Failed");
expect(signinobj2.bell.isPresent()).toBe(true, "Test Case Failed");
signinobj2.avatar.click();
}
)
})
Please open you web application in browser and check that locator mentioned in exception is present