0

I am working on an test automation and using protractor with jasmine framework. While handling an autocomplete select (selection drop-down i.e countries' name drop-down). I wanna send keys to this autocomplete select drop down in the way as browser.actions().mouseMove(addMember.getLocationInput().sendKeys('UAE')).perform(); but it creates a syntax error. When i remove sendKeys('UAE') it removes syntax error but i have to send keys to it. Can any one help me to send keys to this autocomplete select. You can find the complete test case in the attached file. Thanks in advance

it('Should add Instructor successfully',()=>{
        return new Promise((res)=>{
            let email = Math.floor(Math.random()*10000)+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','Instructor')).click();
                    addMember.getCountryCodeInput().element(by.cssContainingText("option","UAE (+65)")).click();
                    addMember.getPhoneNumberInput().sendKeys('231321321321'); 
                    //Here is the syntax error
                    browser.actions().mouseMove(addMember.getLocation().sendKeys('UAE')).perform(); 
                    browser.actions().sendKeys(Key.ARROW_DOWN).perform();
                    browser.actions().sendKeys(Key.ENTER).perform();
                    addMember.getSaveButton().click();
                    return new Promise((resolve)=>{
                        setTimeout(()=>{
                        expect(browser.getCurrentUrl()).toContain('people').then(()=>{
                            resolve();
                            res();
                            })
                        },browser.params.Waiting_time.AVERAGE);
                    });
                },browser.params.Waiting_time.HIGH);
            });
        });
    });
Analyst
  • 751
  • 6
  • 15

2 Answers2

1

I think that mouse move can't go in combination with sendKeys as you are doing. First you move the mouse over the element like this:

browser.actions().mouseMove(addMember.getLocation()).perform(); 

And then if you want to send keys, you need another code:

addMember.getLocation().sendKeys('UAE');
Sanja Paskova
  • 1,110
  • 8
  • 15
0

I solved my above mentioned problem by Changing browser.actions().mouseMove(addMember.getLocation()).perform() to browser.actions().mouseDown(addMember.getLocation()).perform() which moves to the element, clicks there and then sendKeys() can be called

Analyst
  • 751
  • 6
  • 15