public string GetSelectedVenue() { if (PlatformName.Equals(MobilePlatform.IOS)) { return(VenuePicker.FindElement(MobileBy.AccessibilityId("VenueInformation")).GetAttribute("value")); } return(VenuePicker.FindElement(By.Id("android:id/text1")).Text); }
public void deveMudarHora() { page.clicarTexto("06:00"); page.clicar(MobileBy.AccessibilityId("10")); page.clicar(MobileBy.AccessibilityId("40")); page.clicarTexto("OK"); Assert.True(page.existeElementoPorTexto("10:40")); }
public void TapElementWeFind() { driver.LaunchApp(); var ListView = driver.FindElement(MobileBy.ClassName("ListView")); ListView.Click(); driver.CloseApp(); }
public AndroidElement FindByXPath(string xpath) { AndroidElement element = (AndroidElement) new WebDriverWait( driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable( MobileBy.XPath(xpath)) ); return(element); }
public void TestLoginPageLoads() { LoginPage lp = new LoginPage(TestBase.driver); TestBase.wait.Until(ExpectedConditions.ElementIsVisible(MobileBy.AccessibilityId("email"))); foreach (IWebElement e in lp.GetMainElements()) { Assert.That(e.Displayed); } }
public void validaValorSnacks() { TimeSpan period = TimeSpan.FromSeconds(2); int tryCount = 2; if (tryCount <= 0) { throw new ArgumentOutOfRangeException(nameof(tryCount)); } Cinemas cinemas = new Cinemas(); cinemas.EscolherCinemaComSucesso(); while (true) { try { AndroidElement menu_snackbar = _driver.FindElementById(menuSnackBar); menu_snackbar.Click(); break; } catch (StaleElementReferenceException) { if (--tryCount == 0) { throw; } Common.WaitAndRetry(period); } } AndroidElement pipocas = _driver.FindElementByXPath(menuPipocas); pipocas.Click(); AndroidElement add_pipocas1 = _driver.FindElement(MobileBy.AndroidUIAutomator(addPipocas1)); add_pipocas1.Click(); AndroidElement add_pipocas2 = _driver.FindElement(MobileBy.AndroidUIAutomator(addPipocas2)); add_pipocas2.Click(); AndroidElement preco_pipocas1 = _driver.FindElement(MobileBy.AndroidUIAutomator(precoPipocas1)); decimal preco1 = Decimal.Parse(preco_pipocas1.Text, NumberStyles.Currency); AndroidElement preco_pipocas2 = _driver.FindElement(MobileBy.AndroidUIAutomator(precoPipocas2)); decimal preco2 = Decimal.Parse(preco_pipocas2.Text, NumberStyles.Currency); AndroidElement soma_valor_snacks = _driver.FindElementById(somaValorSnacks); decimal soma_final = Decimal.Parse(soma_valor_snacks.Text, NumberStyles.Currency); if (!(preco1 + preco2 == soma_final)) { throw new ArgumentException("App nao esta somando os valores corretamente"); } }
static void Main(string[] args) { AppiumOptions caps = new AppiumOptions(); // Set your BrowserStack access credentials caps.AddAdditionalCapability("browserstack.user", "YOUR_USERNAME"); caps.AddAdditionalCapability("browserstack.key", "YOUR_ACCESS_KEY"); // Set URL of the application under test caps.AddAdditionalCapability("app", "bs://<app-id>"); // Specify device and os_version caps.AddAdditionalCapability("device", "Google Pixel 3"); caps.AddAdditionalCapability("os_version", "9.0"); // Specify the platform name caps.PlatformName = "Android"; // Set other BrowserStack capabilities caps.AddAdditionalCapability("project", "First CSharp project"); caps.AddAdditionalCapability("build", "CSharp Android"); caps.AddAdditionalCapability("name", "first_test"); // Initialize the remote Webdriver using BrowserStack remote URL // and desired capabilities defined above AndroidDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>( new Uri("http://hub-cloud.browserstack.com/wd/hub"), caps); // Test case for the BrowserStack sample Android app. // If you have uploaded your app, update the test case here. AndroidElement searchElement = (AndroidElement) new WebDriverWait( driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable( MobileBy.AccessibilityId("Search Wikipedia")) ); searchElement.Click(); AndroidElement insertTextElement = (AndroidElement) new WebDriverWait( driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable( MobileBy.Id("org.wikipedia.alpha:id/search_src_text")) ); insertTextElement.SendKeys("BrowserStack"); System.Threading.Thread.Sleep(5000); IReadOnlyList <AndroidElement> allTextViewElements = driver.FindElementsByClassName("android.widget.TextView"); Console.WriteLine(allTextViewElements.Count > 0); // Invoke driver.quit() after the test is done to indicate that the test is completed. driver.Quit(); }
//For Scroll to Element using Text public void scroll_to_element_text_instance(string text, string instance) { Thread.Sleep(3000); var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(" + instance + ")).scrollIntoView(new UiSelector().textContains(\"" + text + "\"));")); if (temp.Count == 0) { throw new Exception(string.Format("Element with the given text: {0} not found on screen", text)); } //var elements = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("+ "new UiSelector().text(\"" + text + "\"));")); }
public void scroll_to_element_by_id(string resource_id) { Thread.Sleep(3000); var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(\"" + resource_id + "\"));")); if (temp.Count == 0) { throw new Exception(string.Format("Element with the given Resource-Id: {0} not found on screen", resource_id)); } //var elements = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("+ "new UiSelector().text(\"" + text + "\"));")); }
public void clicarSeekbar(double posicao) { int delta = 50; AppiumWebElement seek = DriverFactory.getDriver().FindElement(MobileBy.AccessibilityId("slid")); int y = seek.Location.Y + (seek.Size.Height / 2); int xInicial = seek.Location.X + delta; int x = (int)(xInicial + ((seek.Size.Width - 2 * delta) * posicao)); tap(x, y); }
private void WaitForProgressbarToDisapear(AndroidDriver <AppiumWebElement> driver) { var wait = new DefaultWait <AndroidDriver <AppiumWebElement> >(driver) { Timeout = TimeSpan.FromSeconds(60), PollingInterval = TimeSpan.FromMilliseconds(500) }; wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); wait.Until(d => d.FindElement(MobileBy.AccessibilityId("Second item"))); }
public void SelectStatus() { switch (TestBase.mobileOS) { case "IOS": break; case "Android": IWebElement element = Driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"com.shophumm:id/statusCheck\"));")); element.Click(); break; } }
public static void Main(string[] args) { DesiredCapabilities caps = new DesiredCapabilities(); caps.SetCapability("browserstack.user", userName); caps.SetCapability("browserstack.key", accessKey); caps.SetCapability("realMobile", true); caps.SetCapability("device", "iPhone 7"); caps.SetCapability("app", "bs://<hashed app-id>"); IOSDriver <IOSElement> driver = new IOSDriver <IOSElement> (new Uri("http://hub.browserstack.com/wd/hub"), caps); IOSElement loginButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Log In")) ); loginButton.Click(); IOSElement emailTextField = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Email address")) ); // element.SendKeys() method is not supported in Appium 1.6.3 // Workaround for SendKeys() method: emailTextField.Click(); String email = "*****@*****.**"; for (int i = 0; i < email.Length; i++) { driver.FindElementByXPath("//XCUIElementTypeKey[@name='" + email[i] + "']").Click(); } driver.FindElementByAccessibilityId("Next").Click(); System.Threading.Thread.Sleep(5000); IReadOnlyList <IOSElement> textElements = driver.FindElementsByXPath("//XCUIElementTypeStaticText"); String matchedString = ""; foreach (IOSElement textElement in textElements) { String textContent = textElement.Text; if (textContent.Contains("not registered")) { matchedString = textContent; } } Console.WriteLine(matchedString); driver.Quit(); }
public void AddNewItem() { AndroidDriver <AppiumWebElement> driver = StartApp(); // tap on second item var el1 = driver.FindElement(MobileBy.AccessibilityId("Add")); el1.Click(); var elItemText = driver.FindElement(MobileBy.AccessibilityId("ItemText")); elItemText.Clear(); elItemText.SendKeys("This is a new Item"); var elItemDetail = driver.FindElement(MobileBy.AccessibilityId("ItemDescription")); elItemDetail.Clear(); elItemDetail.SendKeys("These are the details"); var elSave = driver.FindElement(MobileBy.AccessibilityId("Save")); elSave.Click(); CreateScreenshot(driver); WaitForProgressbarToDisapear(driver); CreateScreenshot(driver); var scrollableElement = driver.FindElement(MobileBy.AccessibilityId("ItemsListView")); Func <AppiumWebElement> FindElementAction = () => { // find all text views // check if the text matches var elements = driver.FindElementsByClassName("android.widget.TextView"); foreach (var textView in elements) { if (textView.Text == "This is a new Item") { return(textView); } } return(null); }; var elementFound = ScrollUntillItemFound(driver, scrollableElement, FindElementAction, 4); Assert.IsTrue(elementFound != null); driver.CloseApp(); }
public void AddOneSet() { AndroidDriver <AppiumWebElement> driver = StartApp(); var el1 = driver.FindElement(MobileBy.Id("button_toggle_volume")); el1.Click(); var setNumber = driver.FindElement(MobileBy.Id("edit_number_sets")); var numberOfSets = setNumber.Text; var expectedSetNumber = "3"; Assert.IsTrue(numberOfSets == expectedSetNumber); }
public static void Main(string[] args) { Local local = new Local(); List <KeyValuePair <string, string> > options = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("key", accessKey) }; local.start(options); DesiredCapabilities caps = new DesiredCapabilities(); caps.SetCapability("browserstack.user", userName); caps.SetCapability("browserstack.key", accessKey); caps.SetCapability("device", "Google Pixel"); caps.SetCapability("browserstack.local", true); caps.SetCapability("app", "bs://<hashed app-id>"); AndroidDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>(new Uri("http://hub-cloud.browserstack.com/wd/hub"), caps); AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.Id("com.example.android.basicnetworking:id/test_action")) ); searchElement.Click(); AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.ClassName("android.widget.TextView")) ); AndroidElement testElement = null; IReadOnlyList <AndroidElement> allTextViewElements = driver.FindElementsByClassName("android.widget.TextView"); System.Threading.Thread.Sleep(5000); foreach (AndroidElement textElement in allTextViewElements) { if (textElement.Text.Contains("The active connection is")) { testElement = textElement; } } Console.WriteLine(testElement.Text); driver.Quit(); local.stop(); }
static void Main(string[] args) { AppiumOptions caps = new AppiumOptions(); // Set your BrowserStack access credentials caps.AddAdditionalCapability("browserstack.user", "YOUR_USERNAME"); caps.AddAdditionalCapability("browserstack.key", "YOUR_ACCESS_KEY"); // Set URL of the application under test caps.AddAdditionalCapability("app", "bs://<app-id>"); // Specify device and os_version caps.AddAdditionalCapability("device", "iPhone 11 Pro"); caps.AddAdditionalCapability("os_version", "13"); // Specify the platformName caps.PlatformName = "iOS"; // Set other BrowserStack capabilities caps.AddAdditionalCapability("project", "First CSharp project"); caps.AddAdditionalCapability("build", "CSharp iOS"); caps.AddAdditionalCapability("name", "first_test"); // Initialize the remote Webdriver using BrowserStack remote URL // and desired capabilities defined above IOSDriver <IOSElement> driver = new IOSDriver <IOSElement>( new Uri("http://hub-cloud.browserstack.com/wd/hub"), caps); // Test case for the BrowserStack sample iOS app. // If you have uploaded your app, update the test case here. IOSElement textButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button")) ); textButton.Click(); IOSElement textInput = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input")) ); textInput.SendKeys("*****@*****.**" + "\n"); IOSElement textOutput = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output")) ); Assert.AreEqual(textOutput.Text, "*****@*****.**"); driver.Quit(); }
public void scroll_to_element_text_with_parent_sibling(string parent_text, string child) { Thread.Sleep(3000); //string text2 = "Mobile Prepaid and Postpaid Payments"; var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().textContains(\"" + parent_text + "\").fromParent(new UiSelector().textContains(\"" + child + "\")));")); //var temp = driver.FindElements(MobileBy.AndroidUIAutomator("//android.widget.TextView[@resource-id='com.hbl.android.hblmobilebanking:id/limit_title' and @text='Mobile Prepaid and Postpaid Payments']//following-sibling::android.widget.TextView[@resource - id = 'com.hbl.android.hblmobilebanking:id/txn_limit_label']")); //var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0).resourceId(\"" + ali + "\")).scrollIntoView(new UiSelector().textContains(\"" + text + "\").instance(5));")); if (temp.Count == 0) { throw new Exception(string.Format("Element with the given text: {0} and index: {1} not found on screen", parent_text, child)); } //var elements = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("+ "new UiSelector().text(\"" + text + "\"));")); }
public void MasterDetail() { System.Environment.SetEnvironmentVariable("ANDROID_HOME", @"C:\Program Files (x86)\Android\android-sdk"); System.Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin"); var capabilities = new AppiumOptions(); // automatic start of the emulator if not running capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.Avd, "demo_device"); capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AvdArgs, "-no-boot-anim -no-snapshot-load"); capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true); // connecting to a device or emulator capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "2471736c36037ece"); capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2"); // specifyig which app we want to install and launch var currentPath = Directory.GetCurrentDirectory(); Console.WriteLine($"Current path: {currentPath}"); var packagePath = Path.Combine(currentPath, @"..\..\..\AppsToTest\com.fluentbytes.carvedrock-x86.apk"); packagePath = Path.GetFullPath(packagePath); Console.WriteLine($"Package path: {packagePath}"); capabilities.AddAdditionalCapability(MobileCapabilityType.App, packagePath); capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.fluentbytes.carvedrock"); capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "crc641782d5af3c9cf50a.MainActivity"); var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build(); _appiumLocalService.Start();; var driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, capabilities); // tap on second item var el1 = driver.FindElement(MobileBy.AccessibilityId("Second item")); el1.Click(); var el2 = driver.FindElement(MobileBy.AccessibilityId("ItemText")); Assert.IsTrue(el2.Text == "Second item"); driver.PressKeyCode(AndroidKeyCode.Back); var el3 = driver.FindElement(MobileBy.AccessibilityId("Fourth item")); Assert.IsTrue(el3 != null); driver.CloseApp(); }
public static void ScrollDownAndroid(this IWebDriver driver) { IWebElement element = driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"com.shophumm:id/statusCheck\"));")); element.Click(); // Using Touch Action Classes //ITouchAction touchAction = new TouchAction((IPerformsTouchActions)driver); //// get the proper location of where to start to swipe from //Size size = driver.Manage().Window.Size; //int startx = (int)(size.Width / 2); //int starty = (int)(size.Height * 0.8); //int endy = (int)(size.Height * 0.2); //// perform the swipe //driver.Swipe(startx, starty, startx, endy, 3000); }
public static void Main(string[] args) { DesiredCapabilities caps = new DesiredCapabilities(); caps.SetCapability("browserstack.user", userName); caps.SetCapability("browserstack.key", accessKey); caps.SetCapability("device", "iPhone 7"); caps.SetCapability("app", "bs://<hashed app-id>"); IOSDriver <IOSElement> driver = new IOSDriver <IOSElement> (new Uri("http://hub-cloud.browserstack.com/wd/hub"), caps); IOSElement loginButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Log In")) ); loginButton.Click(); IOSElement emailTextField = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Email address")) ); emailTextField.SendKeys("*****@*****.**"); driver.FindElementByAccessibilityId("Next").Click(); System.Threading.Thread.Sleep(5000); IReadOnlyList <IOSElement> textElements = driver.FindElementsByXPath("//XCUIElementTypeStaticText"); String matchedString = ""; foreach (IOSElement textElement in textElements) { try { String textContent = textElement.Text; if (textContent.Contains("not registered")) { matchedString = textContent; } } catch (NullReferenceException) { continue; } } Console.WriteLine(matchedString); driver.Quit(); }
public void ScrollToEndOfListUsingPointerInputDevice() { driver.LaunchApp(); var ListView = driver.FindElement(MobileBy.ClassName("ListView")); // set start point FlickUp(driver, ListView); Thread.Sleep(3000); FlickUp(driver, ListView); Thread.Sleep(3000); driver.CloseApp(); }
public void Login(string username, string password) { var userName = WaitFor.UntilIsVisible( MobileBy.AccessibilityId("test-Username")); userName.SendKeys(username); var passwordField = WaitFor.UntilIsVisible( MobileBy.AccessibilityId("test-Password")); passwordField.SendKeys(password); var login = WaitFor.UntilIsVisible( MobileBy.AccessibilityId("test-LOGIN")); login.Click(); }
public void TestCustomFindElementExtension() { var cap = new AppiumOptions(); cap.AddAdditionalCapability(MobileCapabilityType.App, "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); cap.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows"); cap.AddAdditionalCapability(MobileCapabilityType.DeviceName, "WindowsPC"); var appiumLocalServer = new AppiumServiceBuilder().UsingAnyFreePort().Build(); appiumLocalServer.Start(); var driver = new WindowsDriver <WindowsElement>(appiumLocalServer, cap); // This should fail! "abcxyz" does not exist. driver.FindElement(MobileBy.AccessibilityId("abcxyz"), TimeSpan.FromSeconds(3), TimeSpan.FromMilliseconds(500)); driver.Close(); driver.Dispose(); }
public void ShouldLogin() { var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(20)); var userName = wait.Until(ExpectedConditions.ElementIsVisible( MobileBy.AccessibilityId("test-Username"))); userName.SendKeys("standard_user"); var password = wait.Until(ExpectedConditions.ElementIsVisible( MobileBy.AccessibilityId("test-Password"))); password.SendKeys("secret_sauce"); var login = wait.Until(ExpectedConditions.ElementIsVisible( MobileBy.AccessibilityId("test-LOGIN"))); login.Click(); Assert.DoesNotThrow(() => GetCartElement(wait), "The cart element wasn't displayed"); }
public void CheckMasterDetailAndBack() { AndroidDriver <AppiumWebElement> driver = StartApp(); // tap on second item var el1 = driver.FindElement(MobileBy.AccessibilityId("Second item")); el1.Click(); var el2 = driver.FindElement(MobileBy.AccessibilityId("ItemText")); Assert.IsTrue(el2.Text == "Second item"); driver.PressKeyCode(AndroidKeyCode.Back); var el3 = driver.FindElement(MobileBy.AccessibilityId("Fourth item")); Assert.IsTrue(el3 != null); driver.CloseApp(); }
public static void Main(string[] args) { Local local = new Local(); List <KeyValuePair <string, string> > options = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("key", accessKey) }; local.start(options); DesiredCapabilities caps = new DesiredCapabilities(); caps.SetCapability("browserstack.user", userName); caps.SetCapability("browserstack.key", accessKey); caps.SetCapability("realMobile", true); caps.SetCapability("device", "iPhone 7"); caps.SetCapability("browserstack.local", true); caps.SetCapability("app", "bs://-hashed-id"); IOSDriver <IOSElement> driver = new IOSDriver <IOSElement>(new Uri("http://hub.browserstack.com/wd/hub"), caps); IOSElement testButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal")) ); testButton.Click(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); wait.Until(ExpectedConditions.TextToBePresentInElementValue(driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")), "Response is: Up and running")); IOSElement resultElement = (IOSElement)driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")); Console.WriteLine(resultElement.Text); driver.Quit(); }
public void ShouldLogin() { var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(20)); var userName = wait.Until(ExpectedConditions.ElementIsVisible( MobileBy.AccessibilityId("test-Username"))); userName.SendKeys("standard_user"); var password = wait.Until(ExpectedConditions.ElementIsVisible( MobileBy.AccessibilityId("test-Password"))); password.SendKeys("secret_sauce"); var login = wait.Until(ExpectedConditions.ElementIsVisible( MobileBy.AccessibilityId("test-LOGIN"))); login.Click(); var cartElement = wait.Until(ExpectedConditions.ElementIsVisible( By.XPath("//android.view.ViewGroup[@content-desc='test-Cart']"))); Assert.IsTrue(cartElement.Displayed); }
public void searchWikipedia() { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); AndroidElement searchElement = (AndroidElement)wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia"))); searchElement.Click(); AndroidElement insertTextElement = (AndroidElement)wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("org.wikipedia.alpha:id/search_src_text"))); insertTextElement.SendKeys("Browserstack"); Thread.Sleep(5000); ReadOnlyCollection <AndroidElement> allProductsName = driver.FindElements(By.ClassName("android.widget.TextView")); Assert.True(allProductsName.Count > 0); }
public void AddNewItemWithNewCategory() { var capabilities = new AppiumOptions(); capabilities.AddAdditionalCapability(MobileCapabilityType.App, "8b831c56-bc54-4a8b-af94-a448f80118e7_sezxftbtgh66j!App"); capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows"); capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "WindowsPC"); var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build(); _appiumLocalService.Start(); var driver = new WindowsDriver <WindowsElement>(_appiumLocalService, capabilities); // Create new Category item first var categoryButton = driver.FindElement(MobileBy.AccessibilityId("AddCategory")); categoryButton.Click(); // fill out the form for a new category var categoryName = driver.FindElement(MobileBy.AccessibilityId("categoryName")); categoryName.Clear(); categoryName.SendKeys("New category from automation"); //save category var saveCategory = driver.FindElement(MobileBy.AccessibilityId("Save")); saveCategory.Click(); var el1 = driver.FindElementByAccessibilityId("Add"); el1.Click(); var elItemText = driver.FindElementByAccessibilityId("ItemText"); elItemText.Clear(); elItemText.SendKeys("This is a new Item"); var elItemDetail = driver.FindElementByAccessibilityId("ItemDescription"); elItemDetail.Clear(); elItemDetail.SendKeys("These are the details"); var elItemCategory = driver.FindElement(MobileBy.AccessibilityId("ItemCategory")); elItemCategory.Click(); var categoryListItem = elItemCategory.FindElement(By.Name("New category from automation")); categoryListItem.Click(); var elSave = driver.FindElementByAccessibilityId("Save"); elSave.Click(); elSave.ClearCache(); //wait for progress bar to disapear var wait = new DefaultWait <WindowsDriver <WindowsElement> >(driver) { Timeout = TimeSpan.FromSeconds(60), PollingInterval = TimeSpan.FromMilliseconds(500) }; wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); wait.Until(d => d.FindElementByName("Second item")); var listview = driver.FindElementByAccessibilityId("ItemsListView"); //now use wait to scroll untill we find item wait = new DefaultWait <WindowsDriver <WindowsElement> >(driver) { Timeout = TimeSpan.FromSeconds(60), PollingInterval = TimeSpan.FromMilliseconds(500) }; wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); var elementfound = wait.Until(d => { var input = new PointerInputDevice(PointerKind.Touch); ActionSequence FlickUp = new ActionSequence(input); FlickUp.AddAction(input.CreatePointerMove(listview, 0, 0, TimeSpan.Zero)); FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left)); FlickUp.AddAction(input.CreatePointerMove(listview, 0, -300, TimeSpan.FromMilliseconds(200))); FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left)); driver.PerformActions(new List <ActionSequence>() { FlickUp }); return(d.FindElementByName("This is a new Item")); }); Assert.IsTrue(elementfound != null); driver.CloseApp(); }