How to make protractor capture the browser in the middle of the application

I wrote an angular project that uses require js, so most javascript will not load until landing on a specific set of pages. (including angular.js)

when writing threads I had to use browser.driver instead of ptor, and this worked until the angular components started up. Now I'm trying to find a way to compress ptor initialization in the browser. driver and roll in angular after a certain thread. So I have something like this

browser.driver.getCurrentUrl().then(function(url){ ptor = protractor.getInstance(); // ptor.ignoreSynchronization = true; ptor.get(url); }) ptor.sleep(2000); 

which seems to get ptor undefined after approval, even if I time out. how should i make an exchange here. and make a protractor constructor with a url. without rebooting.

-------------- --------- Addon is ok, that's what I had

  searchInput = browser.driver.findElement(by.css('#searchstring')); searchInput.sendKeys('logan airport'); searchInput.sendKeys(protractor.Key.ENTER)//.perform(); browser.driver.sleep(6000); browser.driver.wait(function(){ //angular loads here return browser.driver.getCurrentUrl(function(url){ searchUrl = url; return /screwdriver/.test(url); }); }, 10000) browser.driver.sleep(2000); /*UNEXECUTED CODE HERE: Error while waiting for angular to sync with your page*/ firstItem = element.all(by.css('.itemContainer')).get(1).click(); browser.driver.sleep(10000); 

and this is what I'm doing right now ...

  searchInput = ptor.findElement(protractor.By.css('#searchstring')); searchInput.sendKeys('logan airport'); searchInput.sendKeys(protractor.Key.ENTER)//.perform(); ptor.sleep(6000); ptor.wait(function(){ //this page loads angular, but stuck on white page, which with previous version this is fluent, it says angular cannot be found on the page return ptor.driver.getCurrentUrl().then(function(url){ searchUrl = url; return /screwdriver/.test(url); }); }, 10000) ptor.sleep(2000); /*NOT EXECUTED: Error while waiting for angular to sync with your page*/ foundItems = ptor.findElement(protractor.By.css('.itemContainer')); firstItem = foundItems.get(1).click(); ptor.sleep(2000); 

both do not work, one is angular not synchronized, the other is angular not found, but the actual page will have angular to exist if u hits f12 and enter angular.

+2
source share
1 answer

In fact, you do not need to create ptor using the new syntax (in the new syntax ptor ~ = browser). ptor.url means "load this page" and not "make a protractor for this page." You probably want something like:

 browser.driver.get(yourUrl); browser.driver.wait(function() { // Put in some test here that returns true when Angular is ready to go. }); element(by.id('foo')); // Start using protractor here! 
+9
source

Source: https://habr.com/ru/post/952136/


All Articles