The task is to insert the name into the input and from the autocomplete a menu will appear in which you need to select the desired name. Here is the site . And here is my code:

 WebDriver driver = new HtmlUnitDriver(); driver.get("http://schedule.npi-tu.ru/application/prep"); WebElement element = driver.findElement(By.name("fio_prep")); element.sendKeys("Кирпиченкова Н В"); WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".ui-autocomplete"))); WebElement listItems = driver.findElement(By.cssSelector(".ui-menu-item")); listItems.click(); driver.quit(); 

    1 answer 1

    Can I explain a little what exactly is the question? Doesn't click happen? Or Should I choose a particular teacher from the list, for example, we drive Ivanov, but we choose Ivanov A? If we know the exact name of the teacher, then this code works 100%, I checked it myself. The code is in python, but since Only 4 lines, I think it will not be difficult to translate it into a used language:

     driver.get("http://schedule.npi-tu.ru/application/prep") wait.until(EC.element_to_be_clickable((By.LINK_TEXT, 'Преподаватели'))) driver.find_element_by_name('fio_prep').send_keys('Иванов И Ю') driver.find_element_by_class_name('ui-menu-item').click() 
    • I did not have a menu. After I enter the text, I tried to download the html page, but received only the original hrml code without a menu - Andrei Sulyz
    • Menu, in the sense of a drop-down list with teachers? In this case, it does not appear, because there was a listItems.click(); event listItems.click(); and the page loads the person’s schedule. To make the menu (drop-down list) appear on the page with the schedule already loaded, you can clear the name entry field and paste it there again, in which case it will appear. - blindeStern
    • No, I am now writing your code and the same error has occurred. It does not find the element 'ui-menu-item'. Displays error. - Andrei Sulyz
    • WebDriver driver = new HtmlUnitDriver (); WebDriverWait wait = new WebDriverWait (driver, 5); driver.get (" schedule.npi-tu.ru/application/prep" ); wait.until (ExpectedConditions.elementToBeClickable (By.linkText ("Teachers"))); driver.findElement (By.name ("fio_prep")). sendKeys ("Ivanov and Yu"); driver.findElement (By.className ("ui-menu-item")). click (); driver.quit (); - Andrei Sulyz
    • Maybe it just does not have time to load the list? Before driver.findElement(By.className("ui-menu-item")).click(); Set the delay in one second - blindeStern