paul-hammant / ngWebDriver

AngularJS and WebDriver bits and pieces for Java (port of Protractor)
MIT License
275 stars 86 forks source link

Javascript error Angular is not defined while accessing the element on angular 8 #94

Closed umeshshende closed 2 years ago

umeshshende commented 4 years ago

Accessing the element on angularjs its working fine but when angular 8 it is throwing Javascript error angular is not defined on last line where ngWebDriver has been called . We also tried with withRootSelector("app-root") as HTML used <app-root></app-root>

NgWebDriver ngWebDriver = new NgWebDriver((JavascriptExecutor) webDriver); WebElement elem = webDriver.findElement(By.id(id)); Object obj = ngWebDriver.retrieve(elem,"companyData");

Reactive form is used in angular 8

paul-hammant commented 4 years ago

Does this work for you ? https://github.com/paul-hammant/ngWebDriver#waiting-for-angular-to-finish-async-activity

umeshshende commented 4 years ago

No.we are doing for the angular 8 now but when we trying to retrieve the object it say angular is not defined. Do you have examples for angular 8 using ngWebDriver accessing reactive form element

paul-hammant commented 4 years ago

I'm not sure what you're telling me. Are you saying that ngWebDriver.waitForAngularRequestsToFinish(); is not to be called for Angular8 webapps?

paul-hammant commented 4 years ago

When I check https://github.com/angular/protractor/commits/master/lib/clientsidescripts.js I note that it has not changed in two years, and the version I have copied into ngWebDriver (and released) is the same as the version that ships with Protractor today.

ghost commented 4 years ago

I've got the same issue, If I run the following test code:

System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); WebDriver driver = new ChromeDriver(); NgWebDriver ngDriver = new NgWebDriver((JavascriptExecutor) driver).withRootSelector("[aio-shell]"); driver.get("https://angular.io/"); ngDriver .waitForAngularRequestsToFinish(); ngDriver.getLocationAbsUrl();

It throws me the error on the last line getting the url:

javascript error: angular is not defined (Session info: chrome=87.0.4280.66) Build info: version: '3.141.59'

Versions:

paul-hammant commented 4 years ago

@bonapat What would be the Angular element in that page that you would interact with?

ghost commented 4 years ago

I want to test a customer angular application and I get that particular error. Just wanted to show that it‘s also reproducible on angular.io page.

On 23 Nov 2020, at 14:26, Paul Hammant notifications@github.com wrote:

 @bonapat What would be the Angular element in that page that you would interact with?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

paul-hammant commented 4 years ago

I can't immediately see any Angular widgets that are shown. The sidebar is closed. I don't know what to click on to open the sidebar. When I do a wget to look at the source of the page before JS has kicked in element you're trying to indicate is an Angular root is empty. I don't know how to help you.

Do you know NodeJS? Maybe you can point Protractor at the same page, and then show it working as you'd expect. If it doesn't work there and you're sure it should, then you can go ahead and raise it with the Protractor team.