Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor Not select first Element from an autocomplete search address

i need to select the first element from an autocomplete search box , when autocomplete shows its hover other element,so other element not clickable by protractor , solution

element.all(by.css('[ng-model="address"]')).get(0) is not work for me but work in another computer , same script work in another computer , i checked protractor version , selenium version
i also try element.all(by.css('[ng-model="address"]')).first() ; its also not work for me , do you have any idea how cant i get first element ?. thanks

enter image description here

like image 933
M_ Fa Avatar asked Feb 11 '23 08:02

M_ Fa


2 Answers

you can send enter key

protractor.Key.ENTER

yourelement.sendKeys('your text to send ', protractor.Key.ENTER);

like image 67
M_ Fa Avatar answered Feb 13 '23 06:02

M_ Fa


The Autocomplete List is only visible if a curser is over the element.

this.selectFirstElement = function(element){
    browser.sleep(3500);
    browser.driver.actions().mouseMove(element);
    element.sendKeys(protractor.Key.ARROW_DOWN);
    element.sendKeys(protractor.Key.TAB);
};
like image 28
Zerocity Avatar answered Feb 13 '23 05:02

Zerocity