Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

I'm getting two different error messages when i'm using page objects with different browser instances in a single test in Protractor #5353

Open
Satish152 opened this issue Nov 16, 2019 · 0 comments

Comments

@Satish152
Copy link

when i tried to use the page objects created with two browser instances, i'm getting two different errors for two different syntaxes.

1. With adding browser instance to the page object##

##PageObject file##

var facebook=function(browserInstance){
	
	browser=browserInstance ? browserInstance : browser;
	element=browser.element;
	
	this.email=function(){
	return element(By.id("email"));
	}
	
	this.password=function(){
		return element(By.id("pass"));
	}
	
	this.submit=function(){
		return element(By.xpath("//input[@aria-label='Log In']"));
	}
	
	this.search=function(){
		return element(By.name('q'));
	}
}


module.exports=facebook;
var page1,page2,utilityInit;
module.exports=function(){
	this.Given(/^Open the browser and Load the URL$/,async function(){
		await browser.get("https://facebook.com");
		browser.logger.info("Title of the window is :"+await browser.getTitle());
		//screenshots.takesScreenshot("filename");
	});

//this function is for first browser instance and facebook pageobject accepts the browser instance as a parameter and based on parameter it will shift the browser instance
this.When(/^User entered the text in the search box$/,async function(){
		browser.sleep(3000);
		page1=new facebook(browser);
		await page1.email().sendKeys(testData.Login.CM[0].Username);
		browser.sleep(3000);
		await page1.password().sendKeys(testData.Login.CM[0].Password);
	});
	
	this.Then(/^User tried to open in new browser instance$/,async function(){
		browser2=await newBrowser.openNewBrowser(browser);
		utilityInit=new utility(browser2);
		utilityInit.ignoreSync(browser2);
		browser2.get("https://google.com");
		page2=new facebook(browser2);
		console.log(await browser2.getTitle()+" title");
		browser2.sleep(5000);
	});
	
	this.When(/^User entered the text in the email field$/,async function(){
		await browser2.page2.search().sendKeys("test");
		browser2.sleep(3000);
	})
}

##error log##

TypeError: Cannot read property 'search' of undefined
    at World.(anonymous) (H:\workspace\Framework\src\test\java\com\learnFramework\TestCases\spec.js:34:24)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

##2.With out adding browser instance to the page objects##

this.When(/^User entered the text in the email field$/,async function(){
		await page2.search().sendKeys("test");
		browser2.sleep(3000);
	})

##error log##

Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping.  See http://git.io/v4gXM for details"

one time it is saying Undefine and one time it is saying angular not found related error.. if anyone faced this type of situation please help me in this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant