Closed julesm007 closed 8 years ago
do you have a reproducible tests to try out ?
Something like this: http://www.w3schools.com/angular/tryit.asp?filename=try_ng_select
Our applications aren't public so can't share them.
did you try using model locator ? - "selectedName"
@julesm007 - take a look at http://stackoverflow.com/questions/4672658/how-do-i-set-an-option-as-selected-using-selenium-webdriver-selenium-2-0-clien there's know-how for arbitrary selection/options widgets there. Indeed, there's a couple of alternate ways of doing it and it can be done with base selenium-java without ngWebDriver.
Now - what is a md-select ? You link to http://www.w3schools.com/angular/tryit.asp?filename=try_ng_select but there is no md-select in there.
Please adivse
It works fine like that :
// Md-Select to select option by text (can't use Select import for that one) public void selectOptionWithText(final WebDriver driver, final WebElement autoCompleteId, final WebElement autoCompleteSearchId, final String textToSelect) { try { final WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOf(autoCompleteId)); autoCompleteId.click(); Thread.sleep(1000); // needed since I tried so many wait and it doesn't work !
final WebElement autoOptions = autoCompleteSearchId;
wait.until(ExpectedConditions.visibilityOf(autoOptions));
final List<WebElement> optionsToSelect = autoOptions.findElements(By.tagName("md-option"));
wait.until(ExpectedConditions.visibilityOfAllElements(optionsToSelect));
for (final WebElement option : optionsToSelect)
{
if (option.getText().equals(textToSelect))
{
System.out.println("Trying to select text: " + textToSelect);
option.click();
break;
}
}
}
catch (final Exception e)
{
System.out.println("Can't work with auto complete");
}
}
i'm new to selenium. i'm having the same issue. what would be autoCompleteId and autoCompleteSearchId in this case?
Can you make a https://codepen.io example that somehow is not touchable by ngWebDriver please?
Thanks!
Hi guys,
I'm having trouble figuring out how to handle md-select elements. I can save the WebElement via model locator but when I try to select something (2nd two lines) the test halts with an error. Is there something else I need to use instead of using "Select" type that I had previously used for non-Angular pages?
Here's a snippet of my code:
WebElement test = driver.findElement(ByAngular.model("requestForProposal.RegionId")); Select select1Selection = new Select(test); // <--- This fails select1Selection.selectByVisibleText("North America"); <--- trying to select this value
Thanks!