public void Test_BookList_Order_Create() { var menubar = header.FindElementByClassName("MyMenuBar"); menubar.FindElementByName("Nhà sách").Click(); var scrollView = header.FindElementByClassName("ScrollViewer"); scrollView.FindElementByClassName("Image").Click(); scrollView.FindElementByName("Thêm vào giỏ hàng").Click(); session.FindElementsByXPath("/Window[@Name=\"MainWindow\"][@AutomationId=\"_MainWindow\"]/Pane[@ClassName=\"Frame\"]/Button[@AutomationId=\"PART_Toggle\"]").Last().Click(); var popup = header.FindElementByClassName("Window"); popup.FindElementByName("Thanh toán").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); header.FindElementsByClassName("ComboBox")[0].SendKeys("Vũ Tuấn Hải"); header.FindElementsByClassName("ComboBox")[1].SendKeys(Keys.ArrowDown + Keys.ArrowDown); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); var x = header.FindElementByName("Thêm hóa đơn thành công"); Assert.IsNotNull(x); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); }
public void MoveAfterMerge() { OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); //create new zones new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-(thumbs[0].Rect.X / 2), 0) .KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift) .Perform(); thumbs = gridEditor.FindElementsByClassName("Thumb"); //merge zones ReadOnlyCollection <WindowsElement> zones = session.FindElementsByClassName("GridZone"); Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10); WindowsElement mergeButton = session.FindElementByName("Merge zones"); Assert.IsNotNull(mergeButton, "Cannot merge: no merge button"); new Actions(session).Click(mergeButton).Perform(); //move thumb AppiumWebElement thumb = thumbs[1]; //thumb from merged zone is still present Move(thumb, 0, false, true); Assert.IsTrue(thumb.Rect.Left <= moveStep); Assert.IsTrue(thumb.Rect.Right > 0); }
public void CreateSplitterWithShiftPressedFocusOnGridEditor() { OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count); Assert.AreEqual(2, thumbs.Count); new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-100, 0) .KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift) .Perform(); Assert.AreEqual(3, gridEditor.FindElementsByClassName("Thumb").Count); ReadOnlyCollection <WindowsElement> zones = session.FindElementsByClassName("GridZone"); Assert.AreEqual(4, zones.Count); //check that zone was splitted vertically Assert.AreEqual(zones[0].Rect.Height, zones[1].Rect.Height); Assert.AreEqual(zones[1].Rect.Height, zones[2].Rect.Height); Assert.AreEqual(zones[2].Rect.Height, zones[3].Rect.Height); }
public void MoveVerticallyWithLimiter() { OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); Assert.AreEqual(3, session.FindElementsByClassName("GridZone").Count); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(2, thumbs.Count); //create new zones new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(0, -(thumbs[0].Rect.Y / 2)) .KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift) .Perform(); thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(4, session.FindElementsByClassName("GridZone").Count); Assert.AreEqual(3, thumbs.Count); //move thumbs AppiumWebElement limiter = gridEditor.FindElementsByClassName("Thumb")[0]; AppiumWebElement movable = gridEditor.FindElementsByClassName("Thumb")[1]; Move(movable, 0, false, false); Assert.IsTrue(movable.Rect.Y > limiter.Rect.Y); Assert.IsTrue(movable.Rect.Y - limiter.Rect.Y < movable.Rect.Height); Move(limiter, limiter.Rect.Y - (limiter.Rect.Y / 2), false, false, -5); Move(movable, 0, false, false); Assert.IsTrue(movable.Rect.Y > limiter.Rect.Y); Assert.IsTrue(movable.Rect.Y - limiter.Rect.Y < movable.Rect.Height); }
public void CreateSplitter() { OpenCreatorWindow("Columns", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); ReadOnlyCollection <AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone"); Assert.AreEqual(3, zones.Count, "Zones count invalid"); const int defaultSpacing = 16; int splitPos = zones[0].Rect.Y + zones[0].Rect.Height / 2; new Actions(session).MoveToElement(zones[0]).Click().Perform(); zones = gridEditor.FindElementsByClassName("GridZone"); Assert.AreEqual(4, zones.Count); //check splitted zone Assert.AreEqual(zones[0].Rect.Top, defaultSpacing); Assert.IsTrue(Math.Abs(zones[0].Rect.Bottom - splitPos + defaultSpacing / 2) <= 2); Assert.IsTrue(Math.Abs(zones[1].Rect.Top - splitPos - defaultSpacing / 2) <= 2); Assert.AreEqual(zones[1].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing); }
public void Test_BookManager_2_Edit(string d1, string d2, string d3) { var menubar = header.FindElementByClassName("MyMenuBar"); menubar.FindElementByName("Kho sách").Click(); var frame = header.FindElementByClassName("Frame"); frame.FindElementByName("Thông tin").Click(); header.FindElementByName("ID").Click(); header.FindElementByName("ID").Click(); var item = header.FindElementsByClassName("DataGridCell").Where(x => x.Text == d1).SingleOrDefault(); item.Click(); frame.FindElementByName("Sửa").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); var tbs = header.FindElementsByClassName("TextBox"); tbs[0].SendKeys(Keys.LeftControl + "a"); tbs[0].SendKeys(Keys.Backspace + d2); tbs[6].SendKeys(Keys.LeftControl + "a"); tbs[6].SendKeys(Keys.Backspace + d3); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); Assert.AreEqual("Sửa thành công", header.FindElementByClassName("TextBlock").Text); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); }
public void MoveVerticalSplitter() { OpenCreatorWindow("Columns", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(2, thumbs.Count); //move left for (int i = 0; i < thumbs.Count; i++) { AppiumWebElement thumb = thumbs[i]; int border = i == 0 ? 0 : thumbs[i - 1].Rect.Right; Move(thumb, border, false, true); Assert.IsTrue(thumb.Rect.Left - border <= moveStep); Assert.IsTrue(thumb.Rect.Right > border); } //move right for (int i = thumbs.Count - 1; i >= 0; i--) { AppiumWebElement thumb = thumbs[i]; int border = i == thumbs.Count - 1 ? Screen.PrimaryScreen.WorkingArea.Right : thumbs[i + 1].Rect.Left; Move(thumb, border, true, true); Assert.IsTrue(border - thumb.Rect.Right <= moveStep); Assert.IsTrue(thumb.Rect.Left < border); } //move up foreach (AppiumWebElement thumb in thumbs) { int expected = thumb.Rect.X; Move(thumb, 0, false, false); int actual = thumb.Rect.X; Assert.AreEqual(expected, actual); } //move down foreach (AppiumWebElement thumb in thumbs) { int expected = thumb.Rect.X; Move(thumb, Screen.PrimaryScreen.WorkingArea.Right, true, false); int actual = thumb.Rect.X; Assert.AreEqual(expected, actual); } }
public void TTXK_047_XuatKho(object ghichu, object sachIndex, object quantity) { button_Them.Click(); Thread.Sleep(100); SwitchToPopupWindow(); window_Them = session.FindElementByXPath("/Window[@ClassName=\"Window\"][@AutomationId=\"_ThongTinChiTiet_XK\"]"); var textboxes = window_Them.FindElementsByClassName("TextBox"); textboxes[0].SendKeys(ghichu.ToString()); OpenWindow_ThemSach(); Combobox_ChonSach((int)sachIndex); Thread.Sleep(100); NhapSoLuongSach((int)quantity); Thread.Sleep(100); session.FindElementByName("Thêm").Click(); Thread.Sleep(100); SwitchToPopupWindow(); session.FindElementByName("Đồng ý").Click(); SwitchToPopupWindow(); }
public void KH038_XoaKhachHang(object rowIndex) { var rows = table_KhachHang.FindElementsByClassName("DataGridRow"); var preCount = rows.Count; var actions = new Actions(session); actions.MoveToElement(rows[(int)rowIndex]).Perform(); actions.MoveByOffset(-300, 0).Perform(); actions.Click().Perform(); session.FindElementByName("Xóa").Click(); rows = table_KhachHang.FindElementsByClassName("DataGridRow"); Assert.AreEqual(preCount - 1, rows.Count); }
public void FindElementsByClassName() { var elements = homePagePivot.FindElementsByClassName("PivotItem"); Assert.IsNotNull(elements); Assert.AreEqual(4, elements.Count); Assert.IsTrue(elements.Contains(alarmTabElement)); }
public void TestSplitterShiftAfterCreation() { OpenCreatorWindow("Columns", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); ReadOnlyCollection <AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone"); Assert.AreEqual(3, zones.Count, "Zones count invalid"); const int defaultSpacing = 16; //create first split int firstSplitPos = zones[0].Rect.Y + zones[0].Rect.Height / 4; new Actions(session).MoveToElement(zones[0]).MoveByOffset(0, -(zones[0].Rect.Height / 4)).Click().Perform(); zones = gridEditor.FindElementsByClassName("GridZone"); Assert.AreEqual(4, zones.Count); Assert.AreEqual(zones[0].Rect.Top, defaultSpacing); Assert.IsTrue(Math.Abs(zones[0].Rect.Bottom - firstSplitPos + defaultSpacing / 2) <= 2); Assert.IsTrue(Math.Abs(zones[1].Rect.Top - firstSplitPos - defaultSpacing / 2) <= 2); Assert.AreEqual(zones[3].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing); //create second split int secondSplitPos = zones[3].Rect.Y + zones[3].Rect.Height / 2; int expectedTop = zones[3].Rect.Top; new Actions(session).MoveToElement(zones[3]).Click().Perform(); zones = gridEditor.FindElementsByClassName("GridZone"); Assert.AreEqual(5, zones.Count); //check first split on same position Assert.AreEqual(zones[0].Rect.Top, defaultSpacing); Assert.IsTrue(Math.Abs(zones[0].Rect.Bottom - firstSplitPos + defaultSpacing / 2) <= 2); //check second split Assert.AreEqual(zones[3].Rect.Top, expectedTop); Assert.IsTrue(Math.Abs(zones[3].Rect.Bottom - secondSplitPos + defaultSpacing / 2) <= 2); Assert.IsTrue(Math.Abs(zones[4].Rect.Top - secondSplitPos - defaultSpacing / 2) <= 2); Assert.AreEqual(zones[4].Rect.Bottom, Screen.PrimaryScreen.Bounds.Bottom - defaultSpacing); }
/// <summary> /// Initializes a new instance of the <see cref="LandingScreen"/> class. /// </summary> /// <param name="vpnSession">VPN session.</param> public LandingScreen(WindowsDriver <WindowsElement> vpnSession) { WindowsElement landingView = vpnSession.FindElementByClassName("LandingView"); var titles = landingView.FindElementsByClassName("TextBlock"); this.titleElement = titles[0]; this.subTitleElement = titles[1]; this.getStartedButton = landingView.FindElementByName("Get started"); this.learnMoreHyperlink = landingView.FindElementByName("Learn more"); }
/// <summary> /// Initializes a new instance of the <see cref="VerifyAccountScreen"/> class. /// </summary> /// <param name="vpnSession">VPN session.</param> public VerifyAccountScreen(WindowsDriver <WindowsElement> vpnSession) { WindowsElement landingView = vpnSession.FindElementByClassName("VerifyAccountView"); var titles = landingView.FindElementsByClassName("TextBlock"); this.titleElement = titles[0]; this.cancelTryAgainButton = titles[1]; this.spinner = landingView.FindElementByClassName("Spinner"); Assert.IsNotNull(this.spinner); }
public void TTTK015_CapNhatThongTin(object tenTK, object gioitinhIndex, object sdt, object diachi) { Open_Window_CapNhatThongTin(); var textboxes = window_CapNhatThongTin.FindElementsByClassName("TextBox"); textboxes[0].SendKeys(Keys.LeftControl + "a"); textboxes[0].SendKeys((string)tenTK); Chon_GioiTinh((int)gioitinhIndex); textboxes[3].SendKeys(Keys.LeftControl + "a"); textboxes[3].SendKeys((string)sdt); textboxes[5].SendKeys(Keys.LeftControl + "a"); textboxes[5].SendKeys((string)diachi); window_CapNhatThongTin.FindElementByName("Cập nhật").Click(); SwitchToPopupWindow(); Assert.AreEqual(session.FindElementByName((string)tenTK).Text, (string)tenTK); }
public void MoveHorizontallyWithLimiter() { OpenCreatorWindow("Columns", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); Assert.AreEqual(3, gridEditor.FindElementsByClassName("GridZone").Count); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(2, thumbs.Count); //create new zones new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-30, 0) .KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift) .Perform(); thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(4, gridEditor.FindElementsByClassName("GridZone").Count); Assert.AreEqual(3, thumbs.Count); //move thumbs AppiumWebElement limiter = gridEditor.FindElementsByClassName("Thumb")[0]; AppiumWebElement movable = gridEditor.FindElementsByClassName("Thumb")[1]; Move(movable, 0, false, true); Assert.IsTrue(movable.Rect.X > limiter.Rect.X); Assert.IsTrue(movable.Rect.X - limiter.Rect.X < movable.Rect.Width); Move(limiter, limiter.Rect.X - (limiter.Rect.X / 2), false, true); Move(movable, 0, false, true); Assert.IsTrue(movable.Rect.X > limiter.Rect.X); Assert.IsTrue(movable.Rect.X - limiter.Rect.X < movable.Rect.Width); }
public void MergeZones() { OpenCreatorWindow("Columns", "Custom table layout creator", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); ReadOnlyCollection <WindowsElement> zones = session.FindElementsByClassName("GridZone"); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(3, zones.Count); Assert.AreEqual(2, thumbs.Count); Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10); WindowsElement mergeButton = session.FindElementByName("Merge zones"); Assert.IsNotNull(mergeButton, "Cannot merge: no merge button"); new Actions(session).Click(mergeButton).Perform(); Assert.AreEqual(2, session.FindElementsByClassName("GridZone").Count); Assert.AreEqual(1, gridEditor.FindElementsByClassName("Thumb").Count); }
public void Test_BookManager_1_Add(string d1, string d2, string d3, string d4, string d5, string d6, string d7, string d8) { var img = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Images\tieng-viet-1.jpg"); var menubar = header.FindElementByClassName("MyMenuBar"); menubar.FindElementByName("Kho sách").Click(); var frame = header.FindElementByClassName("Frame"); frame.FindElementByName("Thông tin").Click(); frame.FindElementByAccessibilityId("AddBtn").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); var tbs = header.FindElementsByClassName("TextBox"); tbs[0].SendKeys(d1); tbs[1].SendKeys(d2); tbs[2].SendKeys(d3); tbs[3].SendKeys(d4); tbs[4].SendKeys(d5); tbs[5].SendKeys(d7); tbs[6].SendKeys(d8); tbs[7].SendKeys(d6 + Keys.Enter); header.FindElementByAccessibilityId("ChooseImageBtn").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByName("Open"); var comboBox = header.FindElementByClassName("ComboBox"); comboBox.FindElementByClassName("Edit").SendKeys(img + Keys.Enter); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); Assert.AreEqual("Thêm sách thành công", header.FindElementByClassName("TextBlock").Text); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); var c = header.FindElementsByClassName("DataGridCell").Where(x => x.Text == d2).Count(); Assert.AreNotEqual(0, c); }
public void TTXK048_XuatKho_KhongChonSach(object ghichu, object sachIndex, object quantity) { button_Them.Click(); Thread.Sleep(100); SwitchToPopupWindow(); window_Them = session.FindElementByXPath("/Window[@ClassName=\"Window\"][@AutomationId=\"_ThongTinChiTiet_XK\"]"); var textboxes = window_Them.FindElementsByClassName("TextBox"); textboxes[0].SendKeys(ghichu.ToString()); OpenWindow_ThemSach(); Thread.Sleep(100); NhapSoLuongSach((int)quantity); bool button_Them_Disabled = !session.FindElementByName("Thêm").Enabled; Assert.IsTrue(button_Them_Disabled); CloseWindow_ThemSach(); CloseWindow_XuatKho(); }
public override IEnumerable <AppiumWebElement> FindAllElements(WindowsElement element) { return(element.FindElementsByClassName(Value)); }