Test autocomplete with Selenium webdriver

后端 未结 3 1587
感动是毒
感动是毒 2020-12-06 07:09

I have a text box in which when I type one letter say \'s\' , it displays a list of results ( like google search) .

I am using latest selenium webdriver with java. <

3条回答
  •  一向
    一向 (楼主)
    2020-12-06 07:38

    I found a workaround about this. My problem was:

    1. Selenium inputted 'Mandaluyong' to an auto-suggest location field
    2. The auto-suggest field appears together with the matched option
    3. Then selenium left the auto-suggest drop-down open not selecting the matched option.

    What I did was:

            driver.findElement(By.name("fromLocation")).sendKeys("Mandaluyong");
            driver.findElement(By.name("fromLocation")).sendKeys(Keys.TAB);
    

    This is because on a manual test, when I try to press TAB key, two things were done by the system:

    1. Picks the matched option from the auto-suggest drop-down
    2. Closes the auto-suggest drop-down

提交回复
热议问题