1

Я использую Selenium 3.0 и firefox 48 для автоматизации приложения. Но в firefox48 автоматизировать выбор drop down не работает.Выберите drop down не работает в firefox 48, используя selenium webdriver

Тот же код отлично работает для IE и хром.

Это проблема с браузером или кодом?

enter image description here

Select sel = new Select(driver.findElement(By.xpath("//select[contains(@id,'BusinessUnit')]"))); 
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ctl00_vmsContent_rdwBusinessUnit_C_selBusinessUnit"))); 
List<WebElement> list = sel.getOptions(); 
for (WebElement el : list) 
{ 
    System.out.println(el.getText()); 
    sel.selectByIndex(2); 
} 
+0

Попробуйте этот ответ http://stackoverflow.com/questions/39224373/unable-to-select-dropdown-option-after-updating-jar-files-to-selenium-3-0/39228389#39228389 –

+0

@naveen, вы получаете какую-либо ошибку? –

ответ

0

Я бы рационализировать код немного. Я добавил небольшой код для отладки.

// wait until returns a WebElement, store it for later use 
WebElement e = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//select[contains(@id,'BusinessUnit')]"))); 
// dump the HTML of the select element and make sure you have the element you are expecting 
System.out.println(e.getAttribute("outerHTML")); 
Select sel = new Select(e); 
for (WebElement el : sel.getOptions()) 
{ 
    System.out.println(el.getText()); 
} 
sel.selectByIndex(2); // pull this out of the loop or it will get selected mutliple times 
// other options for selecting the desired OPTION 
sel.selectByValue("12"); 
sel.selectByVisibleText("Engineering"); 
+0

У вас есть решение? – HemaSundar

+0

@HemaSundar Конечно, в моем ответе выше. Я смущен тем, что вы просите. – JeffC

 Смежные вопросы

  • Нет связанных вопросов^_^