public static void Main(string[] args) { AppiumOptions caps = new AppiumOptions(); caps.AddAdditionalCapability("key", System.Environment.GetEnvironmentVariable(MainClass.key)); caps.AddAdditionalCapability("secret", System.Environment.GetEnvironmentVariable(MainClass.secret)); caps.AddAdditionalCapability("deviceName", "Galaxy S9"); caps.AddAdditionalCapability("version", "9.0"); caps.AddAdditionalCapability("app", System.Environment.GetEnvironmentVariable("TB_APP_ID")); var driver = new AndroidDriver <AndroidElement>(new Uri("https://hub.testingbot.com/wd/hub"), caps, TimeSpan.FromSeconds(120)); AndroidElement inputA = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("inputA")) ); inputA.SendKeys("10"); AndroidElement inputB = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("inputB")) ); inputB.SendKeys("5"); System.Threading.Thread.Sleep(2000); driver.Quit(); }
private void LoginScreenIsVisible() { var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(20)); wait.Until(ExpectedConditions.ElementIsVisible( MobileBy.AccessibilityId("test-Username"))); }
public void testLocal() { 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")); String resultString = resultElement.Text.ToLower(); if (resultString.Contains("not working")) { Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot(); string screenshot = ss.AsBase64EncodedString; byte[] screenshotAsByteArray = ss.AsByteArray; ss.SaveAsFile("screenshot", ScreenshotImageFormat.Png); ss.ToString(); } String expectedString = "Up and running"; Assert.True(resultString.Contains(expectedString.ToLower())); }
// https://developer.android.com/intl/ru/training/accessibility/accessible-app.html (contentDescription or name) // https://developer.apple.com/reference/uikit/uiaccessibilityidentification (accessibilityIdentifier or name) public static Search AccessibilityId(string accessibilityId) { return(new Search { Wrapper = MobileBy.AccessibilityId(accessibilityId) }); }
public void SearchParserByFunctionTest() { const string locator = "abc"; var searchParser = new SearchParser("AccessibilityID", locator); Assert.AreEqual(searchParser.By, MobileBy.AccessibilityId(locator)); searchParser = new SearchParser("classname", locator); Assert.AreEqual(searchParser.By, By.ClassName(locator)); searchParser = new SearchParser("CssSelector", locator); Assert.AreEqual(searchParser.By, By.CssSelector(locator)); searchParser = new SearchParser("id", locator); Assert.AreEqual(searchParser.By, By.Id(locator)); searchParser = new SearchParser("IOSCLASSCHAIN", locator); Assert.AreEqual(searchParser.By, MobileBy.IosClassChain(locator)); searchParser = new SearchParser("iosNSpredicate", locator); Assert.AreEqual(searchParser.By, MobileBy.IosNSPredicate(locator)); searchParser = new SearchParser("IOSUIAutomation", locator); Assert.AreEqual(searchParser.By, MobileBy.IosUIAutomation(locator)); searchParser = new SearchParser("LINKTEXT", locator); Assert.AreEqual(searchParser.By, By.LinkText(locator)); searchParser = new SearchParser("NaMe", locator); Assert.AreEqual(searchParser.By, By.Name(locator)); searchParser = new SearchParser("PartialLINKTEXT", locator); Assert.AreEqual(searchParser.By, By.PartialLinkText(locator)); searchParser = new SearchParser("Tagname", locator); Assert.AreEqual(searchParser.By, By.TagName(locator)); searchParser = new SearchParser("TizenAutomation", locator); Assert.AreEqual(searchParser.By, MobileBy.TizenAutomation(locator)); searchParser = new SearchParser("WindowsAutomation", locator); Assert.AreEqual(searchParser.By, MobileBy.WindowsAutomation(locator)); searchParser = new SearchParser("XPath", locator); Assert.AreEqual(searchParser.By, By.XPath(locator)); }
private static IWebElement FindElementDiffMethods(IWebDriver driver, string element) { IWebElement resElement = null; try { if (driver is AndroidDriver <AppiumWebElement> ) { resElement = driver.FindElement(MobileBy.AndroidUIAutomator("new UiSelector().textContains(\"" + element + "\")")); } else if (driver is IOSDriver <AppiumWebElement> ) { resElement = driver.FindElement(MobileBy.AccessibilityId(element)); } else { throw new OpenQA.Selenium.WebDriverException("WRONG DRIVER"); } } catch (OpenQA.Selenium.NoSuchElementException) { try { resElement = driver.FindElement(By.ClassName(element)); } catch (OpenQA.Selenium.NoSuchElementException) { resElement = driver.FindElement(By.Id(element)); } } return(resElement); }
private bool IsLoginButtonDisplayed() { var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(30)); var loginButton = wait.Until(ExpectedConditions.ElementIsVisible(MobileBy.AccessibilityId("test-LOGIN"))); return(loginButton.Displayed); }
public void TestFindElement() { var appId = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"; var platformName = "Windows"; var deviceName = "WindowsPC"; var cap = new AppiumOptions(); cap.AddAdditionalCapability(MobileCapabilityType.App, appId); cap.AddAdditionalCapability(MobileCapabilityType.PlatformName, platformName); cap.AddAdditionalCapability(MobileCapabilityType.DeviceName, deviceName); var appiumLocalServer = new AppiumServiceBuilder().UsingAnyFreePort().Build(); appiumLocalServer.Start(); var driver = new WindowsDriver <WindowsElement>(appiumLocalServer, cap); var btn7 = MobileBy.AccessibilityId("num7Button"); var btn1 = MobileBy.AccessibilityId("num1Button"); var btnEquals = MobileBy.AccessibilityId("equalButton"); var btnPlus = MobileBy.AccessibilityId("plusButton"); driver.FindElement(btn7).Click(); driver.FindElement(btn7).Click(); driver.FindElement(btnPlus).Click(); driver.FindElement(btn1).Click(); driver.FindElement(btn1).Click(); driver.FindElement(btnEquals).Click(); driver.Close(); driver.Dispose(); }
public static void Main(string[] args) { AppiumOptions caps = new AppiumOptions(); caps.AddAdditionalCapability("key", System.Environment.GetEnvironmentVariable(MainClass.key)); caps.AddAdditionalCapability("secret", System.Environment.GetEnvironmentVariable(MainClass.secret)); caps.AddAdditionalCapability("deviceName", "iPhone 11"); caps.AddAdditionalCapability("version", "13.4"); caps.AddAdditionalCapability("app", System.Environment.GetEnvironmentVariable("TB_APP_ID")); IOSDriver <IOSElement> driver = new IOSDriver <IOSElement> (new Uri("http://hub.testingbot.com/wd/hub"), caps, TimeSpan.FromSeconds(300)); IOSElement inputA = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ElementToBeClickable(MobileBy.AccessibilityId("inputA")) ); inputA.SendKeys("10"); IOSElement inputB = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ElementToBeClickable(MobileBy.AccessibilityId("inputB")) ); inputB.SendKeys("5"); IOSElement sum = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ElementToBeClickable(MobileBy.AccessibilityId("sum")) ); Console.WriteLine(sum); driver.Quit(); }
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", "Google Pixel"); caps.SetCapability("app", "bs://<hashed app-id>"); AndroidDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>(new Uri("http://hub.browserstack.com/wd/hub"), caps); AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia")) ); searchElement.Click(); AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.Id("org.wikipedia.alpha:id/search_src_text")) ); insertTextElement.SendKeys("BrowserStack"); System.Threading.Thread.Sleep(5000); driver.Quit(); }
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 textButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button")) ); textButton.Click(); IOSElement textInput = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input")) ); textInput.SendKeys("*****@*****.**"); IOSElement textOutput = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output")) ); Assert.AreEqual(textOutput.Text, "*****@*****.**"); driver.Quit(); }
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 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 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); } }
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(); }
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 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); }
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(); }
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 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 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 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(); }