简体   繁体   中英

browser actions doesn't work in headless chrome

In angular test automation, I am using some mouse and keyboard actions ie mouseDown , Key.ENTER and Key.ARROW_DOWN in my it block. It superbly works in browser (actual browser). The same test case fails and I am sure it fails due to browser.actions().SOMEACTION() in headless browser. I have searched but didn't find any solution. Attached is the file for failing test case. Will be thankful for your kind help.

 it('Should add Dispatcher successfully',()=>{ return new Promise((res)=>{ let email = Math.floor(Math.random()*100000)+1; addMember.getAddMemberSubMenu().click().then(()=>{ setTimeout(()=>{ addMember.getFirstNameInput().sendKeys("John"); addMember.getLastNameInput().sendKeys("Doe"); addMember.getEmailInput().sendKeys(email+"@gmail.com") addMember.getUserRolesInput().element(by.cssContainingText('option','Dispatcher')).click(); addMember.getPhoneNumberInput().sendKeys('03133535058'); browser.actions().mouseDown(addMember.getLocationInput()).perform(); //problem starts here browser.actions().sendKeys(Key.ARROW_DOWN).perform(); browser.actions().sendKeys(Key.ENTER).perform(); addMember.getSaveButton().click().then(()=>{ return new Promise((resolve)=>{ setTimeout(()=>{ expect(browser.getCurrentUrl()).toContain('people').then(()=>{ resolve(); res(); }); },browser.params.Waiting_time.HIGH); }); }); },browser.params.Waiting_time.HIGH); }) }); });

I solved this by passing window size argument in chromeOptions as

capabilities: {
  chromeOptions: {
    args: [ "--headless","--window-size=1600x1200"] //window-size
  },
browserName: 'chrome'

},

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