SelectOptionAsync

Parent Previous Next

SelectOptionAsync

Description: the method selects an option from the select element by the specified index, text, or value. 

Syntax: SelectOptionAsync(string by, string value)

Return value: no return value


Example:

Tester tester = new Tester(browserForm);

await tester.TestBeginAsync();

await tester.GoToUrlAsync("https://somovstudio.github.io/test2.html", 5);

HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "//*[@id='MySelect']");

await element.SelectOptionAsync(HTMLElement.BY_INDEX, "2");

await element.SelectOptionAsync(HTMLElement.BY_VALUE, "Mobile");

await element.SelectOptionAsync(HTMLElement.BY_TEXT, "Other");

string index = await element.GetOptionAsync(HTMLElement.BY_INDEX);

string text = await element.GetOptionAsync(HTMLElement.BY_TEXT);

string value = await element.GetOptionAsync(HTMLElement.BY_VALUE);

...

await tester.TestEndAsync();

Created with the Personal Edition of HelpNDoc: Free EPub and documentation generator