public static void TestClickComboBox(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var comboBox = wd.GetElement("css selector", "select"); Assertions.Equal(true, comboBox != null); var text = wd.ElementState(comboBox, "text"); Assertions.Equal("", text.Value <string>()); var items = wd.GetElements("css selector", "select > option").ToList(); Assertions.Equal(3, items.Count); var texts = items.Select(handle => { var txt = wd.ElementState(handle, "text"); return(txt.Value <string>()); }).ToList(); Assertions.Equal("First", texts[0]); Assertions.Equal("Second", texts[1]); Assertions.Equal("Third", texts[2]); wd.Click(items[0]); var selected = wd.ElementState(items[0], "selected"); Assertions.Equal(true, selected.Value <bool>()); }
public JToken ElementState(string handle, string req) { var obj = GetSessionCommand("element/" + handle + "/" + req); Assertions.Equal("success", obj.Value <string>("status")); var x = obj["value"]; return(x); }
public static void TestReadAllComboBoxes(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var values = wd.GetElements("css selector", "select").ToList(); Assertions.Equal(2, values.Count); }
public static void TestSource(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var res = wd.GetSessionCommand("source"); Assertions.Equal("success", res.Value <string>("status")); Assertions.Equal(true, res["value"] != null); }
public static void TestLabelText(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var value = wd.GetElement("link text", "A label"); Assertions.Equal(true, null != value); }
public static void TestCheckboxAfterButton(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var element = wd.GetElement("css selector", "button ~ input[type=\"checkbox\"]"); Assertions.Equal(true, element != null); }
public static void TestGetSecondTextBox(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var element = wd.GetElement("css selector", "input[type=\"text\"] + input[type=\"text\"]"); Assertions.Equal(true, element != null); }
public static void TestTitle(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var res = wd.GetSessionCommand("title"); Assertions.Equal("success", res.Value <string>("status")); Assertions.Equal("Form1", res.Value <string>("value")); }
public static void TestFullScreenshot(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var res = wd.GetSessionCommand("screenshot"); Assertions.Equal(wd.SessionID, res.Value <string>("sessionId")); Assertions.Equal("success", res.Value <string>("status")); byte[] bytes = Convert.FromBase64String(res.Value <string>("value")); }
public static void ElementEnabled(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var b1 = wd.GetElement("link text", "Bouton1"); var enabled = wd.ElementState(b1, "enabled"); Assertions.Equal(false, enabled.Value <bool>()); }
public static void DisabledButtonClick(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var Bouton1 = wd.GetElement("link text", "Bouton1"); // should fail with an error here! var res = wd.PostFaultySessionCommand("element/" + Bouton1 + "/click", new object()); Assertions.Equal("element not interactable", res["value"].Value <string>("error")); }
public string GetElement(string @using, string value) { var res = PostSessionCommand("element", new { @using = @using, value = value }); Assertions.Equal("success", res.Value <string>("status")); var x = res.Value <string>("value"); return(x); }
public static void TestClick(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var Bouton1 = wd.GetElement("link text", "Bouton1"); var OtherButton = wd.GetElement("link text", "OtherButton"); wd.Click(OtherButton); var x = wd.GetElement("link text", "Clicked"); Assertions.Equal(OtherButton, x); }
public static void TestReadAllCheckBoxes(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var checkboxes = wd.GetElements("css selector", "input[type=\"checkbox\"]").ToList(); Assertions.Equal(2, checkboxes.Count); var check = wd.GetElement("css selector", "input[checked=\"false\"]"); Assertions.Equal(checkboxes[1], check); }
public static void ElementText(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var c1 = wd.GetElement("link text", "My checkbox"); var text = wd.ElementState(c1, "text"); Assertions.Equal("My checkbox", text.Value <string>()); var b1 = wd.GetElement("link text", "Premier"); text = wd.ElementState(b1, "text"); Assertions.Equal("Premier", text.Value <string>()); }
public static void TestElement1(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var res = wd.PostSessionCommand("element", new { @using = "link text", value = "OtherButton" }); Assertions.Equal("success", res.Value <string>("status")); // one element handle as a string Assertions.Equal(true, null != res.Value <string>("value")); }
public static void ElementSelectedCheckbox(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var c1 = wd.GetElement("link text", "My checkbox"); var selected1 = wd.ElementState(c1, "selected"); Assertions.Equal(false, selected1.Value <bool>()); var c2 = wd.GetElement("link text", "My checkbox checked"); var selected2 = wd.ElementState(c2, "selected"); Assertions.Equal(true, selected2.Value <bool>()); }
public static void TestCheckBox(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var cb1 = wd.GetElement("link text", "My checkbox checked"); Assertions.Equal(true, cb1 != null); wd.Click(cb1); var cbs = wd.GetElements("css selector", "input[type=\"checkbox\"]").ToList(); Assertions.Equal(2, cbs.Count); }
public static void ElementSelectedRadio(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var r1 = wd.GetElement("link text", "First Radio"); var selected1 = wd.ElementState(r1, "selected"); Assertions.Equal(true, selected1.Value <bool>()); var r2 = wd.GetElement("link text", "Second Radio"); var selected2 = wd.ElementState(r2, "selected"); Assertions.Equal(false, selected2.Value <bool>()); }
public IEnumerable <string> GetElements(string @using, string value) { var res = PostSessionCommand("elements", new { @using = @using, value = value }); Assertions.Equal("success", res.Value <string>("status")); var elements = (JArray)res["value"]; foreach (var elem in elements) { var handle = elem.Value <string>(); yield return(handle); } }
public static void TestTextEntry(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var tb1 = wd.GetElement("css selector", "input[type=\"text\"]"); Assertions.Equal(true, tb1 != null); wd.Clear(tb1); wd.SendKeys(tb1, "HELLO"); var tb = wd.GetElement("link text", "HELLO"); Assertions.Equal(tb1, tb); }
public static void TestReadAllButtons(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var res = wd.PostSessionCommand("elements", new { @using = "tag name", value = "button" }); Assertions.Equal("success", res.Value <string>("status")); var elements = (JArray)res["value"]; Assertions.Equal(3, elements.Count); foreach (var elem in elements) { var handle = elem.Value <string>(); // at least we got the handle } }
public static void TestSIP(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var btn = wd.GetElement("link text", "dlg"); wd.Click(btn); var tb1 = wd.GetElement("css selector", "input[type=\"text\"]"); Assertions.Equal(true, tb1 != null); // when we do this, the SIP is opened, which interferes // with input wd.Clear(tb1); wd.SendKeys(tb1, "HELLO"); var tb = wd.GetElement("link text", "HELLO"); Assertions.Equal(tb1, tb); }
public static void TestRadioBox(string endpoint) { var wd = new WebDriver(endpoint); wd.Session(SUT, null); var rb1 = wd.GetElement("link text", "First Radio"); Assertions.Equal(true, rb1 != null); var rb2 = wd.GetElement("link text", "Second Radio"); Assertions.Equal(true, rb2 != null); wd.Click(rb2); var r1 = wd.ElementState(rb1, "selected"); Assertions.Equal(false, r1.Value <bool>()); var r2 = wd.ElementState(rb2, "selected"); Assertions.Equal(true, r2.Value <bool>()); }