GetElementAsync

Parent Previous Next

GetElementAsync

Description: the method returns an element in the form of an object whose class HTMLElement

Syntax: GetElementAsync(string by, string locator)

Return value: object HTMLElement



Example:

HTMLElement element = await tester.GetElementAsync(Tester.BY_CSS, "#auth #buttonLogin");

await element.ClickAsync();


HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "//div[@id='auth']//input[@id='buttonLogin']");

await element.ClickAsync();


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

tester.ConsoleMsg("ID: " + element.Id);


HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "//h1");

string text = await element.GetTextAsync();

tester.ConsoleMsg(text);

await element.SetTextAsync("text");


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

await element.SetValueAsync("text");

string value = await element.GetValueAsync();

tester.ConsoleMsg(value);


HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "//h1");

await element.SetAttributeAsync("class", "my-class");

string attrClass = await element.GetAttributeAsync("class");

tester.ConsoleMsg(attrClass);


HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "//h1");

string html = await element.GetHtmlAsync();

tester.ConsoleMsg(html);


HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "//h1");

await element.SetHtmlAsync("<div>text</div>");


HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "/html/body/footer");

await element.ScrollToAsync();


HTMLElement element = await tester.GetElementAsync(Tester.BY_XPATH, "//h1");

await element.WaitVisibleAsync(2);

await element.WaitNotVisibleAsync(2);

Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation