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); }); }); });

9
  • 2
    addMember.getLocationInput().sendKeys('UAE') returns promise not the element. But mousemove expects an element. So you have an syntax error Commented Jan 14, 2020 at 8:52
  • why dont you sendkeys to location element before mousemove? Commented Jan 14, 2020 at 8:53
  • It says that element not interactable Commented Jan 14, 2020 at 9:44
  • @VolkanAlbayrak I have seen that another tutorial that it is possible to send keys to mouseMove() Commented Jan 14, 2020 at 9:47
  • 1
    @VolkanAlbayrak it is like browser.actions().mouseMove(element(by.model("location")).sendKeys("london")).perform() Commented Jan 14, 2020 at 9:50

2 Answers 2

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'); 
Sign up to request clarification or add additional context in comments.

1 Comment

I have tried it. It says that element not interactable
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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.