public void Test_Login_Valid(string object1, string object2) { header.FindElementByClassName("TextBox").SendKeys(Keys.LeftControl + "a"); header.FindElementByClassName("TextBox").SendKeys(object1); header.FindElementByClassName("PasswordBox").SendKeys(Keys.LeftControl + "a"); header.FindElementByClassName("PasswordBox").SendKeys(object2); header.FindElementByXPath("/Window[@AutomationId=\"_Login\"]/Button[@ClassName=\"Button\"][@Name=\"Login\"]").Click(); var result = header.FindElementByAccessibilityId("Warning").Text; Assert.AreNotEqual("Sai tài khoản hoặc mật khẩu", result); }
static WindowsElement FindElement(this WindowsElement scroll, TypeEnum @enum, string eleName) { AppiumWebElement ele = null; switch (@enum) { case TypeEnum.AccessibilityId: { ele = scroll.FindElementByAccessibilityId(eleName); break; } case TypeEnum.Name: { ele = scroll.FindElementByName(eleName); break; } case TypeEnum.TagName: { ele = scroll.FindElementByTagName(eleName); break; } case TypeEnum.XPath: { ele = scroll.FindElementByXPath(eleName); break; } default: break; } return(ele as WindowsElement); }
private static void SetUpElements() { tab_KhachHang = menuBar.FindElementByName("Khách hàng") as WindowsElement; tab_KhachHang.Click(); panel_KhachHang = mainAppHeader.FindElementByTagName("Pane") as WindowsElement; table_KhachHang = panel_KhachHang.FindElementByClassName("DataGrid") as WindowsElement; button_Them = panel_KhachHang.FindElementByXPath("/Pane[@ClassName=\"Frame\"]/Custom[@AutomationId=\"_uc\"]/Button[@AutomationId=\"PART_Toggle\"]") as WindowsElement; }
public static void AutoLogin() { loginHeader.FindElementByClassName("TextBox").SendKeys(Keys.LeftControl + "a"); loginHeader.FindElementByClassName("TextBox").SendKeys("admin"); loginHeader.FindElementByClassName("PasswordBox").SendKeys(Keys.LeftControl + "a"); loginHeader.FindElementByClassName("PasswordBox").SendKeys("admin"); loginHeader.FindElementByXPath("/Window[@AutomationId=\"_Login\"]/Button[@ClassName=\"Button\"][@Name=\"Login\"]").Click(); }
private static void SetUpElements() { tab_KhoSach = menuBar.FindElementByName("Kho sách") as WindowsElement; tab_KhoSach.Click(); panel_KhoSach = mainAppHeader.FindElementByTagName("Pane") as WindowsElement; tab_XuatKho = panel_KhoSach.FindElementByName("Xuất kho") as WindowsElement; tab_XuatKho.Click(); button_Them = panel_KhoSach.FindElementByXPath("/Pane[@ClassName=\"Frame\"]/Pane[@ClassName=\"Frame\"]/Button[@ClassName=\"Button\"]") as WindowsElement; }
public TweetDesktopControl(WindowsElement element) : base(element) { var tweetTextElement = element.FindElementByXPath("/Group/Group/Group/Group/Text"); Tweet = new Tweet { Message = tweetTextElement.Text, }; }
public void TestInitialize() { Setup(null); header = session.FindElementByAccessibilityId("_Login"); header.FindElementByClassName("TextBox").SendKeys(Keys.LeftControl + "a" + Keys.LeftControl); header.FindElementByClassName("TextBox").SendKeys("admin"); header.FindElementByClassName("PasswordBox").SendKeys(Keys.LeftControl + "a" + Keys.LeftControl); header.FindElementByClassName("PasswordBox").SendKeys("admin"); header.FindElementByXPath("/Window[@AutomationId=\"_Login\"]/Button[@ClassName=\"Button\"][@Name=\"Login\"]").Click(); Thread.Sleep(100); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByXPath("/Window[@Name=\"MainWindow\"][@AutomationId=\"_MainWindow\"]"); }
public async Task InputTextAndClickSearchButtonAndResultLoads() { session.FindElementByAccessibilityId("SearchTextBox").SendKeys("Foo"); session.FindElementByAccessibilityId("SearchButton").Click(); await Task.Delay(1000); WindowsElement searchResults = session.FindElementByAccessibilityId("SearchResults"); AppiumWebElement resultItem = searchResults.FindElementByXPath("//*[contains(@Name, \"Result 1\")]"); Assert.NotNull(resultItem); }
protected static void OpenCreatorWindow(string tabName, string buttonId = "EditCustomButton") { try { editorWindow.FindElementByName(tabName).Click(); editorWindow.FindElementByAccessibilityId(buttonId).Click(); creatorWindow = editorWindow.FindElementByXPath("//Window"); Assert.IsNotNull(creatorWindow, "Creator window didn't open"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void FindNestedElement_ByXPath() { // Different Alarm & Clock application version uses different UI elements if (AlarmTabClassName == "ListViewItem") { WindowsElement ancestorElement = session.FindElementByClassName("ApplicationBar"); WindowsElement element = ancestorElement.FindElementByXPath("//Button[@AutomationId=\"MoreButton\"]") as WindowsElement; Assert.IsNotNull(element); } else { WindowsElement element = alarmTabElement.FindElementByXPath("//Button[@AutomationId=\"MoreButton\"]") as WindowsElement; Assert.IsNotNull(element); } }
public override AppiumWebElement FindElement(WindowsElement element) { return(element.FindElementByXPath(string.Format(XpathEndingWithExpression, Value))); }
public override AppiumWebElement FindElement(WindowsElement element) { return(element.FindElementByXPath(Value)); }
public void CreateMesh1() { Driver.FindElementByName("Open...").Click(); System.Threading.Thread.Sleep(1000); action = new Actions(Driver); Assert.IsNotNull(action); action.SendKeys(@"D:\TechnoStar\Mazda\R2-IDI3_TS.jtdb"); action.SendKeys(Keys.Enter); action.Perform(); Driver.FindElementByName("Assembly").Click(); allParts = Driver.FindElementByName("All Parts"); var boltOld = allParts.FindElementByXPath("//TreeItem[@Name='bolt_old']"); Assert.IsNotNull(boltOld); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(boltOld); action.ContextClick(); action.SendKeys(Keys.Up); action.SendKeys(Keys.Enter); action.Build().Perform(); var headCyl = allParts.FindElementByXPath("//TreeItem[@Name ='HEAD-CYL']"); Assert.IsNotNull(headCyl); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(headCyl); action.ContextClick(); action.Build().Perform(); Driver.FindElementByXPath("//MenuItem[@Name ='Show Only']").Click(); var geometry = toolBar.FindElementByXPath("//TabItem[@Name ='Geometry']"); geometry.Click(); Driver.FindElementByXPath("//SplitButton[@Name ='Show Adjacent']").Click(); action = new Actions(Driver); Assert.IsNotNull(action); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter); action.Build().Perform(); toolBar.FindElementByName("Home").Click(); var find = Driver.FindElementByName("Find"); Assert.IsNotNull(find); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(find); action.MoveToElement(find, find.Size.Width / 2, find.Size.Height / 3 + 20).Click(); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter); action.Perform(); WindowsElement idBox = Driver.FindElementByAccessibilityId("1582"); Assert.IsNotNull(idBox); InputId(15254, idBox, action, Driver, find); var showAdj = jupiter.FindElementByName("Show Adjacent | Faces"); showAdj.FindElementByName("Stop Face").Click(); InputId(19885, idBox, action, Driver, find); InputId(16323, idBox, action, Driver, find); InputId(20597, idBox, action, Driver, find); InputId(20487, idBox, action, Driver, find); InputId(20596, idBox, action, Driver, find); InputId(20698, idBox, action, Driver, find); InputId(20694, idBox, action, Driver, find); Assert.AreEqual("8", Driver.FindElementByAccessibilityId("5105") .Text.Substring(9).Trim()); var numLayers = showAdj.FindElementByXPath("//Edit[@Name='Number of Layers']"); Assert.IsNotNull(numLayers); numLayers.Clear(); numLayers.SendKeys("100"); showAdj.FindElementByName("Apply").Click(); // Screenshot to compare ? var tools = toolBar.FindElementByName("Tools"); tools.Click(); var modelFilter = Driver.FindElementByName("Model Filter"); Assert.IsNotNull(modelFilter); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(modelFilter); action.MoveToElement(modelFilter, -modelFilter.Size.Width / 2, modelFilter.Size.Height / 2).Click().Perform(); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); var group = jupiter.FindElementByName("Group"); var groupName = group.FindElementByAccessibilityId("1001"); Assert.IsNotNull(groupName); groupName.Clear(); groupName.SendKeys("WaterJacket"); Driver.FindElementByName("OK").Click(); Driver.FindElementByXPath("//Button[@Name='Application menu']").Click(); Driver.FindElementByName("Save As...").Click(); System.Threading.Thread.Sleep(1000); action = new Actions(Driver); action.SendKeys(@"D:\TechnoStar\Mazda\01_Groups.jtdb"); action.SendKeys(Keys.Enter); action.Perform(); }
public void CreateMesh() { Driver.FindElementByName("Open...").Click(); System.Threading.Thread.Sleep(1000); action = new Actions(Driver); Assert.IsNotNull(action); action.SendKeys(@"D:\TechnoStar\Mazda\R2-IDI3_TS.jtdb"); action.SendKeys(Keys.Enter); action.Perform(); Driver.FindElementByName("Assembly").Click(); allParts = Driver.FindElementByName("All Parts"); var boltOld = allParts.FindElementByXPath("//TreeItem[@Name='bolt_old']"); Assert.IsNotNull(boltOld); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(boltOld); action.ContextClick(); action.SendKeys(Keys.Up); action.SendKeys(Keys.Enter); action.Build().Perform(); var headCyl = allParts.FindElementByXPath("//TreeItem[@Name ='HEAD-CYL']"); Assert.IsNotNull(headCyl); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(headCyl); action.ContextClick(); action.Build().Perform(); Driver.FindElementByXPath("//MenuItem[@Name ='Show Only']").Click(); ////////////////////////////////////////////// var geometry = toolBar.FindElementByXPath("//TabItem[@Name ='Geometry']"); geometry.Click(); Driver.FindElementByXPath("//SplitButton[@Name ='Show Adjacent']").Click(); action = new Actions(Driver); Assert.IsNotNull(action); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter); action.Build().Perform(); toolBar.FindElementByName("Home").Click(); var find = Driver.FindElementByName("Find"); Assert.IsNotNull(find); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(find); action.MoveToElement(find, find.Size.Width / 2, find.Size.Height / 3 + 20).Click(); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter); action.Perform(); WindowsElement idBox = Driver.FindElementByAccessibilityId("1582"); Assert.IsNotNull(idBox); InputId(15254, idBox, action, Driver, find); var showAdj = jupiter.FindElementByName("Show Adjacent | Faces"); showAdj.FindElementByName("Stop Face").Click(); InputId(19885, idBox, action, Driver, find); InputId(16323, idBox, action, Driver, find); InputId(20597, idBox, action, Driver, find); InputId(20487, idBox, action, Driver, find); InputId(20596, idBox, action, Driver, find); InputId(20698, idBox, action, Driver, find); InputId(20694, idBox, action, Driver, find); Assert.AreEqual("8", Driver.FindElementByAccessibilityId("5105") .Text.Substring(9).Trim()); var numLayers = showAdj.FindElementByXPath("//Edit[@Name='Number of Layers']"); Assert.IsNotNull(numLayers); numLayers.Clear(); numLayers.SendKeys("100"); showAdj.FindElementByName("Apply").Click(); // Screenshot to compare ? ////////////////////////////////////////////// var tools = toolBar.FindElementByName("Tools"); tools.Click(); var modelFilter = Driver.FindElementByName("Model Filter"); Assert.IsNotNull(modelFilter); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(modelFilter); action.MoveToElement(modelFilter, -modelFilter.Size.Width / 2, modelFilter.Size.Height / 2).Click().Perform(); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); var group = jupiter.FindElementByName("Group"); var groupName = group.FindElementByAccessibilityId("1001"); Assert.IsNotNull(groupName); groupName.Clear(); groupName.SendKeys("WaterJacket"); Driver.FindElementByName("OK").Click(); Driver.FindElementByXPath("//Button[@Name='Application menu']").Click(); Driver.FindElementByName("Save As...").Click(); System.Threading.Thread.Sleep(1000); action = new Actions(Driver); action.SendKeys(@"D:\TechnoStar\Mazda\01_Groups.jtdb"); action.SendKeys(Keys.Enter); action.Perform(); ////////////////////////////////////////////// var meshing = toolBar.FindElementByName("Meshing"); meshing.Click(); var localSettingIcon = Driver.FindElementByName("Local Settings"); action = new Actions(Driver); action.MoveToElement(localSettingIcon, localSettingIcon.Size.Width / 4, localSettingIcon.Size.Height / 2).Click().Perform(); Driver.FindElementByName("Face").Click(); var localSettingName = Driver.FindElementByAccessibilityId("1003"); Assert.IsNotNull(localSettingName); localSettingName.Clear(); localSettingName.SendKeys("WaterJacket"); Driver.FindElementByName("Group").Click(); var waterJacketGroup = Driver.FindElementByName("WaterJacket"); var meshSizeCB = Driver.FindElementByAccessibilityId("1005"); if (!meshSizeCB.Selected) { meshSizeCB.Click(); } Driver.FindElementByAccessibilityId("1006").Clear(); Driver.FindElementByAccessibilityId("1006").SendKeys("1.5"); Driver.FindElementByAccessibilityId("1007").Clear(); Driver.FindElementByAccessibilityId("1007").SendKeys("0.5"); Driver.FindElementByAccessibilityId("1008").Clear(); Driver.FindElementByAccessibilityId("1008").SendKeys("3"); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(waterJacketGroup); action.ContextClick(); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter).Perform(); Driver.FindElementByName("Apply").Click(); ////////////////////////////////////////////// Driver.FindElementByName("Meshing").Click(); action = new Actions(Driver); action.MoveToElement(localSettingIcon, localSettingIcon.Size.Width / 4, localSettingIcon.Size.Height / 2).Click().Perform(); Driver.FindElementByName("Part").Click(); Driver.FindElementByName("Assembly").Click(); var localSettingParts = Driver.FindElementByAccessibilityId("1003"); Assert.IsNotNull(localSettingParts); localSettingParts.Clear(); localSettingParts.SendKeys("Guide-Seat-Valve"); meshSizeCB = Driver.FindElementByAccessibilityId("1005"); if (!meshSizeCB.Selected) { meshSizeCB.Click(); } Driver.FindElementByAccessibilityId("1006").Clear(); Driver.FindElementByAccessibilityId("1006").SendKeys("2"); Driver.FindElementByAccessibilityId("1007").Clear(); Driver.FindElementByAccessibilityId("1007").SendKeys("0.5"); Driver.FindElementByAccessibilityId("1008").Clear(); Driver.FindElementByAccessibilityId("1008").SendKeys("3"); allParts = Driver.FindElementByName("All Parts"); var guide = allParts.FindElementByName("GUIDE-VALVE"); guide.Click(); action = new Actions(Driver); action.KeyDown(Keys.Control).Perform(); allParts.FindElementByName("valve-exh").Click(); allParts.FindElementByName("valve-int").Click(); allParts.FindElementByName("valve-seat-exh").Click(); allParts.FindElementByName("valve-seat-int").Click(); action.MoveToElement(guide); action.ContextClick().Perform(); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter).Perform(); action = new Actions(Driver); action.KeyUp(Keys.Control).Perform(); Driver.FindElementByName("Apply").Click(); Driver.FindElementByXPath("//Button[@Name='Application menu']").Click(); Driver.FindElementByName("Save As...").Click(); System.Threading.Thread.Sleep(1000); var saveText = Driver.FindElementByAccessibilityId("1001"); saveText.SendKeys(@"D:\TechnoStar\Mazda\02_Local_Settings.jtdb"); saveText.SendKeys(Keys.Enter); toolBar.FindElementByName("Meshing").Click(); Driver.FindElementByName("Surface Meshing").Click(); allParts = Driver.FindElementByName("All Parts"); var block = allParts.FindElementByName("BLOCK"); block.Click(); action = new Actions(Driver); action.KeyDown(Keys.Control).Perform(); allParts.FindElementByName("GUIDE-VALVE").Click(); allParts.FindElementByName("HEAD-CYL").Click(); allParts.FindElementByName("liner").Click(); allParts.FindElementByName("valve-exh").Click(); allParts.FindElementByName("valve-int").Click(); allParts.FindElementByName("valve-seat-exh").Click(); allParts.FindElementByName("valve-seat-int").Click(); action.MoveToElement(block); action.ContextClick().Perform(); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter).Perform(); action = new Actions(Driver); action.KeyUp(Keys.Control).Perform(); var meshSurf = jupiter.FindElementByName("Meshing Surf Meshing"); meshSurf.FindElementByAccessibilityId("1001").Clear(); meshSurf.FindElementByAccessibilityId("1001").SendKeys("5"); meshSurf.FindElementByAccessibilityId("1002").Clear(); meshSurf.FindElementByAccessibilityId("1002").SendKeys("1"); meshSurf.FindElementByAccessibilityId("1003").Clear(); meshSurf.FindElementByAccessibilityId("1003").SendKeys("10"); meshSurf.FindElementByAccessibilityId("1004").Clear(); meshSurf.FindElementByAccessibilityId("1004").SendKeys("1"); meshSurf.FindElementByName("OK").Click(); System.Threading.Thread.Sleep(180000); action = new Actions(Driver); action.MoveToElement(meshSurf).Click(); action.SendKeys(Keys.Escape); action.Perform(); Driver.FindElementByXPath("//Button[@Name='Application menu']").Click(); Driver.FindElementByName("Save As...").Click(); System.Threading.Thread.Sleep(1000); saveText = Driver.FindElementByAccessibilityId("1001"); saveText.SendKeys(@"D:\TechnoStar\Mazda\03_Surface_meshing.jtdb"); saveText.SendKeys(Keys.Enter); toolBar.FindElementByName("Mesh Cleanup").Click(); Driver.FindElementByName("Free Edges").Click(); allParts = Driver.FindElementByName("All Parts"); //block = allParts.FindElementByName("BLOCK"); block.Click(); action = new Actions(Driver); action.KeyDown(Keys.Control).Perform(); allParts.FindElementByName("GUIDE-VALVE").Click(); allParts.FindElementByName("HEAD-CYL").Click(); allParts.FindElementByName("liner").Click(); allParts.FindElementByName("valve-exh").Click(); allParts.FindElementByName("valve-int").Click(); allParts.FindElementByName("valve-seat-exh").Click(); allParts.FindElementByName("valve-seat-int").Click(); action.MoveToElement(block); action.ContextClick().Perform(); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter).Perform(); action = new Actions(Driver); action.KeyUp(Keys.Control).Perform(); var freeEdges = jupiter.FindElementByName("Mesh Quality | Free Edges"); var nonManifold = freeEdges.FindElementByAccessibilityId("1008"); if (nonManifold.Selected) { nonManifold.Click(); } freeEdges.FindElementByName("OK").Click(); System.Threading.Thread.Sleep(5000); }