简体   繁体   中英

Running protractor test in firefox clear pop up

I am running protractor End to end test against my angular app. I am not able to clear the pop up using the ENTER or ESCAPE.

await element(by.xpath("//*")).sendKeys(protractor.Key.ENTER); 
or 
await element(by.xpath("//*")).sendKeys(protractor.Key.ESCAPE);

I want to run the test against firefox, I don't have any issue running the test in google chrome Below I have attached the download pop up, I tried changing the settings in browser such that pop doesn't appear but below didn't work for me.

Tools Menu > Options > General Tab > Download Section > clear appropriate check box for downloads window. My firefox version is 82.0

Below is the test

it("should clear the pop up and proceed",async function(){
  await element(by.xpath("//*")).sendKeys(protractor.Key.ESCAPE);
  wait = browser.wait(EC.elementToBeClickable($('#mat-expansion-panel-header-0')), 5000);
  let pageTitle = await browser.getTitle();
  expect(pageTitle).toEqual('xyz');
})

Any suggestion or help on how to clear the pop ups in firefox runnning End to End test will be great!
在此处输入图片说明

Things to know about alert

We cannot identify alerts using inspect tools.

We cannot write xpaths for alerts

It is not a Window

We cannot handle alerts using JavaScript Executor.

It will not allow to performing any other operation o WebPage

Alerts class provides few methods to handle the alerts present in the webpage; using these methods, we can accept, dismiss, get the details of the alerts, and we can set some values as well.

We have to create the object to the Alert class.we can create it like Alert al = new Alert() , but this object represents just a memory address, obvious we can access the methods present inside, but this object does not know, where or on which page this operation should be performed accept() dismiss() getText() sendKeys()

We can create object alerts like below:

let abc:Alert = browser.switchTo().alert(); . Now you can accept or dismiss it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM