GetOptionAsync

Parent Previous Next

GetOptionAsync

Description: the method returns the index, text, or value of the selected option of the selected option from the select element

Syntax: GetOptionAsync(string by)

Return value: string


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: Easily create HTML Help documents