public void Setup() { // Launch Calculator application if it is not yet launched if (session == null) { // Create a new session to bring up an instance of the Calculator application // Note: Multiple calculator windows (instances) share the same process Id Console.WriteLine("Connecting App ..."); Process[] wad = Process.GetProcessesByName("WinAppDriver"); if (wad.Length < 1) { //啓動WinAppDriver.exe Process.Start(@".\Windows Application Driver\WinAppDriver.exe"); } DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", CalculatorAppId); appCapabilities.SetCapability("deviceName", "WindowsPC"); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); // Assert.IsNotNull(session); // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5); session.Manage().Window.Maximize(); //放到最大 } }
public PaintPomBase() { // launch WinAppDriver if (WinAppDriverInstance == null) { WinAppDriverInstance = new WinAppDriverInstance(); } // Launch Paint 3D application if it is not yet launched if (session == null) { // Create a new session to launch Paint 3D application AppiumOptions opt = new AppiumOptions(); opt.AddAdditionalCapability("app", Paint3DAppId); opt.AddAdditionalCapability("deviceName", "WindowsPC"); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), opt); // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5); // Maximize Paint 3D window to ensure all controls being displayed session.Manage().Window.Maximize(); } }
public void SetupBeforeEveryTestMethod() { wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(50)); Assert.IsNotNull(wait); Driver.Manage().Window.Maximize(); jupiter = Driver.FindElementByXPath("//Window[starts-with(@Name,'Jupiter-Pre 5.0')]"); toolBar = Driver.FindElementByName("Ribbon Tabs"); }
public void Test_03_WindowHandle() { Debug.WriteLine("session.CurrentWindowHandle:" + session.CurrentWindowHandle); Debug.WriteLine("session.WindowHandles:" + session.WindowHandles); Debug.WriteLine("session.WindowHandles[0]:" + session.WindowHandles[0]); Debug.WriteLine("session.Manage().Window:" + session.Manage().Window); Debug.WriteLine("session.Manage().Window.Size:" + session.Manage().Window.Size); }
public void CreateNewStickyNote() { var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; const int stickyNoteWidth = 1000; const int stickyNoteHeight = 1000; const int stickyNotePositionX = 100; const int stickyNotePositionY = 100; // Preserve existing or previously opened Sticky Notes by keeping track of them on initialize var openedStickyNotesWindowsBefore = session.FindElementsByClassName("ApplicationFrameWindow"); Assert.IsNotNull(openedStickyNotesWindowsBefore); Assert.IsTrue(openedStickyNotesWindowsBefore.Count > 0); // Create a new Sticky Note by pressing Ctrl + N openedStickyNotesWindowsBefore[0].SendKeys(Keys.Control + "n" + Keys.Control); Thread.Sleep(TimeSpan.FromSeconds(2)); var openedStickyNotesWindowsAfter = session.FindElementsByClassName("ApplicationFrameWindow"); Assert.IsNotNull(openedStickyNotesWindowsAfter); Assert.AreEqual(openedStickyNotesWindowsBefore.Count + 1, openedStickyNotesWindowsAfter.Count); // Identify the newly opened Sticky Note by removing the previously opened ones from the list List <WindowsElement> openedStickyNotes = new List <WindowsElement>(openedStickyNotesWindowsAfter); foreach (var preExistingStickyNote in openedStickyNotesWindowsBefore) { openedStickyNotes.Remove(preExistingStickyNote); } Assert.AreEqual(1, openedStickyNotes.Count); // Create a new session based from the newly opened Sticky Notes window var newStickyNoteWindowHandle = openedStickyNotes[0].GetAttribute("NativeWindowHandle"); newStickyNoteWindowHandle = (int.Parse(newStickyNoteWindowHandle)).ToString("x"); // Convert to Hex AppiumOptions appCapabilities = new AppiumOptions(); appCapabilities.AddAdditionalCapability("appTopLevelWindow", newStickyNoteWindowHandle); appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); newStickyNoteSession = new WindowsDriver <WindowsElement>(serverUri, appCapabilities); Assert.IsNotNull(newStickyNoteSession); // Resize and re-position the Sticky Notes window we are working with newStickyNoteSession.Manage().Window.Size = new Size(stickyNoteWidth, stickyNoteHeight); newStickyNoteSession.Manage().Window.Position = new Point(stickyNotePositionX, stickyNotePositionY); // Verify that this Sticky Notes is indeed new. Newly created Sticky Notes has both // RichEditBox and InkCanvas in the UI tree. Once modified by a pen or key input, // it will only contain one or the other. Assert.IsNotNull(newStickyNoteSession.FindElementByAccessibilityId("RichEditBox")); inkCanvas = newStickyNoteSession.FindElementByAccessibilityId("InkCanvas"); Assert.IsNotNull(inkCanvas); }
public static void CreateSession(TestContext _) { if (_session == null) { int timeoutCount = 50; tryInitializeSession(); if (_session == null) { // WinAppDriver is probably not running, so lets start it! if (File.Exists(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe")) { Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"); } else if (File.Exists(@"C:\Program Files\Windows Application Driver\WinAppDriver.exe")) { Process.Start(@"C:\Program Files\Windows Application Driver\WinAppDriver.exe"); } else { throw new Exception("Unable to start WinAppDriver since no suitable location was found."); } Thread.Sleep(10000); tryInitializeSession(); } while (_session == null && timeoutCount < 1000 * 4) { tryInitializeSession(); Thread.Sleep(timeoutCount); timeoutCount *= 2; } Thread.Sleep(3000); Assert.IsNotNull(_session); Assert.IsNotNull(_session.SessionId); // Dismiss the disclaimer window that may pop up on the very first application launch // If the disclaimer is not found, this throws an exception, so lets catch that try { _session.FindElementByName("Disclaimer").FindElementByName("Accept").Click(); } catch (OpenQA.Selenium.WebDriverException) { } // Wait if something is still animating in the visual tree _session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3); _session.Manage().Window.Maximize(); AxeHelper.InitializeAxe(); } }
public void DoubleTap() { // Launch calculator for this specific test case DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", CommonTestSettings.CalculatorAppId); calculatorSession = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(calculatorSession); Assert.IsNotNull(calculatorSession.SessionId); // Save application window original size and position var originalSize = calculatorSession.Manage().Window.Size; var originalPosition = calculatorSession.Manage().Window.Position; // Get maximized window size calculatorSession.Manage().Window.Maximize(); var maximizedSize = calculatorSession.Manage().Window.Size; Assert.IsNotNull(maximizedSize); // Shrink the window size by 100 pixels each side from maximized size to ensure size changes when maximized int offset = 100; calculatorSession.Manage().Window.Size = new System.Drawing.Size(maximizedSize.Width - offset, maximizedSize.Height - offset); calculatorSession.Manage().Window.Position = new System.Drawing.Point(offset, offset); System.Threading.Thread.Sleep(1000); // Sleep for 1 second var currentWindowSize = calculatorSession.Manage().Window.Size; Assert.IsNotNull(currentWindowSize); Assert.AreNotEqual(maximizedSize.Width, currentWindowSize.Width); Assert.AreNotEqual(maximizedSize.Height, currentWindowSize.Height); // Perform double tap touch on the title bar to maximize calculator window calculatorTouchScreen = new RemoteTouchScreen(calculatorSession); Assert.IsNotNull(calculatorTouchScreen); calculatorTouchScreen.DoubleTap(calculatorSession.FindElementByAccessibilityId("AppNameTitle").Coordinates); System.Threading.Thread.Sleep(1000); // Sleep for 1 second currentWindowSize = calculatorSession.Manage().Window.Size; Assert.IsNotNull(currentWindowSize); Assert.AreEqual(maximizedSize.Width, currentWindowSize.Width); Assert.AreEqual(maximizedSize.Height, currentWindowSize.Height); // Restore application window original size and position calculatorSession.Manage().Window.Size = originalSize; calculatorSession.Manage().Window.Position = originalPosition; System.Threading.Thread.Sleep(1000); // Sleep for 1 second // Close the calculator application and delete the session after cleaning up calculatorTouchScreen = null; calculatorSession.Quit(); calculatorSession = null; }
public void Start() { // Verify Appium server is running Assert.IsTrue(service.IsRunning, "Appium Server is not running!"); // Verify Application exists Assert.IsTrue(File.Exists(settings.AppPath), "Application do not exists at: " + settings.AppPath); // Create a new Appium session to launch application under test AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("app", settings.AppPath); options.AddAdditionalCapability("deviceName", "WindowsPC"); options.AddAdditionalCapability("ms:experimental-webdriver", true); // Add newCommandTimeout if debugger is attached to allow debugging for more than 60 seconds. if (System.Diagnostics.Debugger.IsAttached) { options.AddAdditionalCapability("newCommandTimeout", 3600); } // Start Appium clinet (and application under test) Driver = new WindowsDriver <WindowsElement>(service.ServiceUrl, options); Log.Info("Start Appium session to app under test."); // Set implicit timeout to auto wait for element when try to find it Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(settings.Timeout); // Wait for splash screen to disappear if (settings.AppTitle != null) { var titleFound = Wait.Until(() => GetTitle().Contains(settings.AppTitle), timeout: settings.Timeout); if (!titleFound) { FileSystem.CreateFolder(settings.TestResultsFolder); var failedScreenPath = Path.Combine(settings.TestResultsFolder, "desktop.png"); ImageUtils.SaveScreenshot(failedScreenPath); Assert.Fail("Failed to find window with name: " + settings.AppTitle); } } // Set app possition and size if (settings.Size != null) { Driver.Manage().Window.Position = new Point(0, 0); Driver.Manage().Window.Size = (Size)settings.Size; } else { Driver.Manage().Window.Maximize(); } }
public void TestInit() { var appiumOptions = new AppiumOptions(); appiumOptions.AddAdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC"); _driver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appiumOptions); Assert.IsNotNull(_driver); _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); _calcPage = new CalculatorPage(_driver); _driver.Manage().Window.Maximize(); }
public void WaitForElementById(int timeout, string elementId) { driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(timeout); try { driver.FindElementByAccessibilityId(elementId); } catch { } finally { driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); } }
public void TypeSmthAndAssert() { var appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", NotepadAppId); _driver = new WindowsDriver <WindowsElement>(new Uri(WinAppDriverUrl), appCapabilities); _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); _driver.Manage().Window.Maximize(); _notepad = new NotepadView(_driver); _notepad.TypeAndChangeFont(); Assert.AreEqual("bla-bla-bla, Radinovo 2018", _driver.FindElementByClassName("Edit").Text); }
public void OneTimeSetUp() { reportPath = GlobalTestSetup.reportPath; helper = new Helper(); assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // string projectPath = @"C:\Program Files (x86)\Jenkins\workspace\TestRunner"; //helper.startZeroProcess(); AppiumOptions opt = new AppiumOptions(); opt.AddAdditionalCapability("app", appPath); opt.AddAdditionalCapability("deviceName", "WindowsPC"); driver = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), opt, TimeSpan.FromMinutes(1)); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(40); Thread.Sleep(TimeSpan.FromSeconds(8)); wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); // _waitEl = new WebDriverWait(driver, TimeSpan.FromSeconds(8)); Assert.IsNotNull(wait); helper.waitUntilOutlookOpens(driver); // Return all window handles associated with this process/application. var allWindowHandles = driver.WindowHandles; // Assuming you only have only one window entry in allWindowHandles and it is in fact the correct one, // switch the session to that window as follows. You can repeat this logic with any top window with the same // process id (any entry of allWindowHandles) driver.SwitchTo().Window(allWindowHandles[0]); _BasePage = new BasePage(driver); }
private const int hostedAgentTimer = 0; //45000 public static void Setup(TestContext context) { if (session == null) { // Create a new session to bring up an instance of the Calculator application DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("deviceName", "WindowsPC"); DesktopSession = null; appCapabilities.SetCapability("app", AppId); try { Console.WriteLine("Trying to Launch App"); DesktopSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); } catch { Console.WriteLine("Failed to attach to app session (expected)."); } //Setting thread sleep timer. Hosted Agents take approximately 120 seconds to launch app Thread.Sleep(hostedAgentTimer); appCapabilities.SetCapability("app", "Root"); DesktopSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Console.WriteLine("Attaching to MSIXCatalogMainWindow"); var mainWindow = DesktopSession.FindElementByAccessibilityId("Console Window"); Console.WriteLine("Getting Window Handle"); var mainWindowHandle = mainWindow.GetAttribute("NativeWindowHandle"); mainWindowHandle = (int.Parse(mainWindowHandle)).ToString("x"); // Convert to Hex appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("appTopLevelWindow", mainWindowHandle); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); } }
public static void Setup(TestContext context) { // Uruchom aplikację jeżeli jeszcze nie została uruchomiona if (session == null || touchScreen == null) { TearDown(); //Tworzenie sesji Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"); AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("deviceName", "WindowsPC"); options.AddAdditionalCapability("platformName", "Windows"); options.AddAdditionalCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"); session = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), options); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); Assert.AreEqual("Alarmy i zegar", session.FindElementByName("Alarmy i zegar").Text); // Ustawienie domyślnego limitu czasu na 1.5 sekundy, aby wyszukiwanie elementu powtarzało się co 500mili sekund session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5); touchScreen = new RemoteTouchScreen(session); Assert.IsNotNull(touchScreen); } }
public static void BaseSetup(TestContext context) { if (CalculatorSession == null) { // Launch the calculator app DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); appCapabilities.SetCapability("deviceName", "WindowsPC"); CalculatorSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(CalculatorSession); CalculatorSession.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); // Make sure we're in standard mode CalculatorSession.FindElementByAccessibilityId("NavButton").Click(); OriginalCalculatorMode = CalculatorSession.FindElementByAccessibilityId("FlyoutNav").Text; CalculatorSession.FindElementByName("Standard Calculator").Click(); // Use series of operation to locate the calculator result text element as a workaround CalculatorSession.FindElementByAccessibilityId("clearButton").Click(); CalculatorSession.FindElementByAccessibilityId("num7Button").Click(); CalculatorResult = CalculatorSession.FindElementByAccessibilityId("CalculatorResults"); } Assert.IsNotNull(CalculatorResult); }
public void initDeskTopSession_Implicit() { System.Diagnostics.Debug.WriteLine(string.Format("InitDeskTop Session(BaseManager)")); string platformName = "Windows"; string deviceName = "WindowsPC"; string app_id = "Root"; if (_deskTopSession == null) { try { OpenQA.Selenium.Appium.AppiumOptions ao = new AppiumOptions(); ao.AddAdditionalCapability("app", app_id); ao.AddAdditionalCapability("platformName", platformName); ao.AddAdditionalCapability("deviceName", deviceName); _deskTopSession = new WindowsDriver <WindowsElement>(new Uri(@"http://127.0.0.1:4723"), ao, TimeSpan.FromMinutes(/*2*/ 4)); //2분 응답 Timer설정 // _deskTopSessoin = new WindowsDriver<WindowsElement>(new Uri(@"http://127.0.0.1:4723"), ao); //시간을 주지 않으면, Default 1분 응답 Timer //_deskTopSessoin.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(100); _deskTopSession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(/*30*/ 200); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(string.Format("Full Stacktrace: {0}", ex.ToString())); } } }
public static void Setup(TestContext context) { // Launch Edge browser app if it is not yet launched if (session == null || touchScreen == null || !Utility.CurrentWindowIsAlive(session)) { // Cleanup leftover objects from previous test if exists TearDown(); // Launch the Edge browser app session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private"); session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1)); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Initialize touch screen object touchScreen = new RemoteTouchScreen(session); Assert.IsNotNull(touchScreen); } // Track the Microsoft Edge starting page title to be used to initialize all test cases Thread.Sleep(TimeSpan.FromSeconds(1)); startingPageTitle = session.Title; // Handle Microsoft Edge restored state by starting fresh if (startingPageTitle.StartsWith("Start fresh and ")) { try { session.FindElementByXPath("//Button[@Name='Start fresh']").Click(); Thread.Sleep(TimeSpan.FromSeconds(3)); startingPageTitle = session.Title; } catch { } } }
public static void Setup(TestContext context) { if (Session != null) { return; } var appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", ContosoIncAppId); try { Session = new WindowsDriver <WindowsElement>(new Uri(WinAppDriverUrl), appCapabilities); } catch { Session = new WindowsDriver <WindowsElement>(new Uri(WinAppDriverUrl), appCapabilities); } Thread.Sleep(TimeSpan.FromSeconds(10)); var allWindowHandles = Session.WindowHandles; Session.SwitchTo().Window(allWindowHandles[0]); // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times Session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); }
private void _Login(string login, string password) { var dc = new DesiredCapabilities(); dc.SetCapability("app", this._addmeFileName); _driver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), dc, new TimeSpan(0, 2, 0)); _driver.Manage().Timeouts().ImplicitWait = new TimeSpan(0, 3, 0); _FillData("TextBox1", login); if (password != "password") { _driver.FindElementByAccessibilityId("TextBox2").SendKeys(password); } while (_driver.FindElementByAccessibilityId("Button3").Enabled == false) { _driver.FindElementByAccessibilityId("Button1").Click(); } for (int i = 0; i < 4; i++) { try { _driver.FindElementByAccessibilityId("Button3").Click(); System.Windows.Forms.SendKeys.Send("{ENTER}"); Thread.Sleep(1000); } catch { } } }
public void NavigateForward_Browser() { session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private " + CommonTestSettings.EdgeAboutFlagsURL); session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); Thread.Sleep(TimeSpan.FromSeconds(3)); var originalTitle = session.Title; Assert.AreNotEqual(string.Empty, originalTitle); // Navigate to different URLs session.FindElementByAccessibilityId("addressEditBox").SendKeys(Keys.Alt + 'd' + Keys.Alt + CommonTestSettings.EdgeAboutTabsURL + Keys.Enter); Thread.Sleep(TimeSpan.FromSeconds(2)); var newTitle = session.Title; Assert.AreNotEqual(originalTitle, newTitle); // Navigate back to original URL session.Navigate().Back(); Thread.Sleep(TimeSpan.FromSeconds(2)); Assert.AreNotEqual(newTitle, session.Title); // Navigate forward to original URL session.Navigate().Forward(); Thread.Sleep(TimeSpan.FromSeconds(2)); Assert.AreEqual(newTitle, session.Title); EdgeBase.CloseEdge(session); }
public void VerifyControlPanel() { try { string program = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe"; ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = program; startInfo.UseShellExecute = false; winappListenerProcess = Process.Start(startInfo); appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", "windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"); //Microsoft.Windows.ControlPanel winappDriver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities); winappDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); WindowsElement Accounts = winappDriver.FindElementByName("Accounts"); Accounts.Click(); WindowsElement Yourinfo = winappDriver.FindElementByName("Your info"); Thread.Sleep(3000); Assert.True(Yourinfo.Displayed); Thread.Sleep(3000); } finally { winappDriver.CloseApp(); winappListenerProcess.Kill(); } }
public void VerifyNotepadOperations() { try { string program = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe"; ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = program; startInfo.UseShellExecute = false; winappListenerProcess = Process.Start(startInfo); appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", @"C:\Windows\System32\notepad.exe"); winappDriver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities); winappDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); WindowsElement FileMenu = winappDriver.FindElementByName("File"); Assert.True(FileMenu.Enabled); FileMenu.Click(); WindowsElement ExitButton = winappDriver.FindElementByName("Exit"); Assert.True(ExitButton.Enabled); Thread.Sleep(3000); } finally { winappDriver.CloseApp(); winappListenerProcess.Kill(); } }
public void TestMethod1() { // Launch the calculator app //DesiredCapabilities appCapabilities = new DesiredCapabilities(); //appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); //var CalculatorSession = new RemoteWebDriver(new Uri(" http://127.0.0.1:4723/"), appCapabilities); var options = new AppiumOptions(); options.AddAdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); var CalculatorSession = new WindowsDriver <WindowsElement>(new Uri(" http://127.0.0.1:4723/"), options); Assert.IsNotNull(CalculatorSession); CalculatorSession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); CalculatorSession.FindElementByName("One").Click(); CalculatorSession.FindElementByName("Plus").Click(); CalculatorSession.FindElementByName("Seven").Click(); CalculatorSession.FindElementByName("Equals").Click(); var CalculatorResults = CalculatorSession.FindElementByAccessibilityId("CalculatorResults"); Assert.AreEqual("Display is 8", CalculatorResults.Text); CalculatorSession.Close(); }
public static void Setup(TestContext context) { if (session == null) { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", AppUIBasicAppId); try { session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); } catch { } Thread.Sleep(125000); if (session == null) { session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); } Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Dismiss the disclaimer window that may pop up on the very first application launch try { session.FindElementByName("Disclaimer").FindElementByName("Accept").Click(); } catch { } } session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); }
public static void Setup(TestContext context) { if (session == null) { ReadUserSettings(); //read settings before running tests to restore them after // Create a new Desktop session to use PowerToys. AppiumOptions appiumOptions = new AppiumOptions(); appiumOptions.PlatformName = "Windows"; appiumOptions.AddAdditionalCapability("app", "Root"); try { session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appiumOptions); session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); trayButton = session.FindElementByAccessibilityId("1502"); isPowerToysLaunched = CheckPowerToysLaunched(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public static void Setup(TestContext context) { // Launch a new instance of Notepad application if (session == null) { // Create a new session to launch Notepad application AppiumOptions opt = new AppiumOptions(); opt.AddAdditionalCapability("app", NotepadAppId); opt.AddAdditionalCapability("platformName", "Windows"); opt.AddAdditionalCapability("deviceName", "WindowsPC"); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), opt); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Verify that Notepad is started with untitled new file // IMPORTANT NOTE FOR ERRORS: If your Windows language is not English, you need to adjust the string to your localised text. (Also other texts in this demo.) Assert.AreEqual("Untitled - Notepad", session.Title); // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5); // Keep track of the edit box to be used throughout the session editBox = session.FindElementByClassName("Edit"); Assert.IsNotNull(editBox); } }
public void OneTimeSetUpBase() { this.testDb = new TestDb(); this.dbContext = testDb.CreateDbContext(); this.testEventuresApp = new TestEventuresApp <Startup>(testDb, ApiPath); this.baseUrl = this.testEventuresApp.ServerUri; // Initialize Appium Local Service to start the Appium server automatically appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build(); appiumLocalService.Start(); var appiumOptions = new AppiumOptions() { PlatformName = "Windows" }; var fullPathName = Path.GetFullPath(AppPath); appiumOptions.AddAdditionalCapability("app", fullPathName); // Initialize the Windows driver with Appium local service and options driver = new WindowsDriver <WindowsElement>( appiumLocalService, appiumOptions); // Set an implicit wait for the UI interaction driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); // Set an explicit wait for the UI interaction wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); }
public static void Setup(TestContext context) { // Launch a new instance of Notepad application if (session == null) { // Create a new session to launch Notepad application DesiredCapabilities appCapabilities = new DesiredCapabilities(); //app = Path of your WPF application. appCapabilities.SetCapability("app", thickClientAppID); //WinAppDriverURI runs here http://127.0.0.1:4723 session = new WindowsDriver <AppiumWebElement>(new Uri(WinAppDriverURI), appCapabilities); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Verify that Notepad is started with untitled new file Assert.AreEqual("MainWindow", session.Title); // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1.5)); // Keep track of the edit box to be used throughout the session //FirstName = session.FindElementByXPath("//TextBox[contains(text(), 'Nirav')]"); FirstName = session.FindElementByAccessibilityId("TBFirstName"); Assert.IsNotNull(FirstName); } }
public static void Setup(TestContext context) { // Launch the App UI Basic app // Ensure AppUIBasics app has been installed in the device // Below are steps to install the AppUIBasics. These steps only need to be executed once // 1. Open ApplicationUnderTests\AppUIBasics\AppUIBasics.sln solution in Visual Studio // 2. Select the correct configuration for the device (e.g. x86) and Run the application // 3. The application will then be installed. You can safely close the AppUIBasics app & project if (session == null) { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", AppUIBasicAppId); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Dismiss the disclaimer window that may pop up on the very first application launch try { session.FindElementByName("Disclaimer").FindElementByName("Accept").Click(); } catch { } session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); } }
public static void SetUp(TestContext context) { //launch app if it isn't launched if (session == null) { //create new session //note: multiple instances share the same process id //DesiredCapabilities appCap = new DesiredCapabilities(); //appCap.SetCapability("app", CalculatorAppId); //appCap.SetCapability("deviceName", "WindowsPC"); //windowSession = new WindowsDriver<WindowsElement>(new Uri(WindowAppDriverURL), appCap); //session = new WindowsDriver<WindowsElement>(remoteAddress: new Uri(WindowAppDriverURL), AppiumOptions: appCap); //# Desired Capability is obsolete repleaced with AppiumOptions in Appium Package 4.0#// AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("deviceName", "WindowsPC"); options.AddAdditionalCapability("platformName", "Windows"); options.AddAdditionalCapability("app", CalculatorAppId); session = new WindowsDriver <WindowsElement>(new Uri(WindowAppDriverURL), options); //Set implicit timeout to 1 second to make element search to retry every 500 ms for at most 3 times session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); Assert.IsNotNull(session); } }