public void FindByAccessibilityIdTest() { By byAccessibilityId = new ByAccessibilityId("ComputeSumButton"); Assert.AreNotEqual(driver.FindElement(byAccessibilityId).Text, null); Assert.GreaterOrEqual(driver.FindElements(byAccessibilityId).Count, 1); }
public virtual bool HasNavigationBarTitled(string title, int timeoutSecs) { var xpath = "//UIANavigationBar[1]/UIAStaticText[@label='" + title + "']"; var element = Driver.FindElement(By.XPath(xpath), timeoutSecs); return(element != null); }
public void ScrollToTestCase() { AppiumWebElement slider = driver .FindElement(new ByIosUIAutomation(".tableViews()[0]" + ".scrollToElementWithPredicate(\"name CONTAINS 'Slider'\")")); Assert.AreEqual(slider.GetAttribute("name"), "Sliders"); }
public void TapElementWeFind() { driver.LaunchApp(); var ListView = driver.FindElement(MobileBy.ClassName("ListView")); ListView.Click(); driver.CloseApp(); }
public void RunAction() { // Create Action var action = new ClearFieldsAction(); // Prepare state driver.FindElement(By.Id("name")).SendKeys("John Smith"); driver.FindElement(By.Id("password")).SendKeys("12345"); // Run action runner.Run(action); }
public void TestiOSApp() { driver.FindElement(By.XPath("xpath=//*[@text='Username']")).SendKeys("company"); driver.FindElement(By.XPath("xpath=//*[@text='Password']")).SendKeys("company"); driver.FindElement(By.XPath("xpath=//*[@text='loginButton']")).Click(); driver.FindElement(By.XPath("xpath=//*[@text='makePaymentButton']")).Click(); driver.FindElement(By.XPath("xpath=//*[@text='Phone']")).SendKeys("123456"); driver.FindElement(By.XPath("xpath=//*[@text='Name']")).SendKeys("Test"); driver.FindElement(By.XPath("xpath=//*[@text='Amount']")).SendKeys("10"); driver.FindElement(By.XPath("xpath=//*[@text='Country']")).SendKeys("US"); driver.FindElement(By.XPath("xpath=//*[@text='sendPaymentButton']")).Click(); driver.FindElement(By.XPath("xpath=//*[@text='Yes']")).Click(); }
public void TestiOSApp() { driver.Navigate().GoToUrl("https://amazon.com"); if (driver.Capabilities.GetCapability("device.category").Equals("TABLET")) { driver.FindElement(By.XPath("//*[@name='field-keywords']")).SendKeys("iPhone"); driver.FindElement(By.XPath("//*[@text='Go']")).Click(); } else { driver.FindElement(By.XPath("//*[@name='k']")).SendKeys("iPhone"); driver.FindElement(By.XPath("//*[@value='Go']")).Click(); } }
public void Appium_iOS_CheckRegionWithIgnoreRegion() { var labelInContainer = driver_.FindElement(labelInContainerSelector_); eyes_.Check("Image Container", Target.Region(containerSelector_).Ignore(labelInContainer).Ignore(imageInContainerSelector_)); expectedIgnoreRegions_ = new HashSet <Region>() { new Region(115, 35, 113, 65), new Region(0, 0, 343, 21) }; }
// IOS Finder public IOSElement TDFinder(string propType, string propValue, IOSDriver <IOSElement> _driverIOS) { IOSElement eToUse = null; switch (propType) { case "Id": eToUse = _driverIOS.FindElement(By.Id(propValue)); break; case "Name": eToUse = _driverIOS.FindElement(By.Name(propValue)); break; case "Class": eToUse = _driverIOS.FindElement(By.ClassName(propValue)); break; case "CssSelector": eToUse = _driverIOS.FindElement(By.CssSelector(propValue)); break; case "LinkText": eToUse = _driverIOS.FindElement(By.LinkText(propValue)); break; case "XPath": eToUse = _driverIOS.FindElement(By.XPath(propValue)); break; } return(eToUse); }
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 FindByClassChainTest() { ReadOnlyCollection <AppiumWebElement> sliderCellStaticTextElements_1 = driver .FindElements(new ByIosClassChain("**/XCUIElementTypeCell/XCUIElementTypeStaticText[`name == 'Sliders'`]")); Assert.AreEqual(sliderCellStaticTextElements_1.Count, 1); ReadOnlyCollection <AppiumWebElement> sliderCellStaticTextElements_2 = driver .FindElementsByIosClassChain("**/XCUIElementTypeCell"); Assert.AreEqual(sliderCellStaticTextElements_2.Count, 18); AppiumWebElement actionSheetsCell = driver.FindElement(new ByIosClassChain("**/XCUIElementTypeCell/XCUIElementTypeStaticText[`name == 'Action Sheets'`]")); actionSheetsCell.Tap(1, 250); driver.FindElementByIosClassChain("**/XCUIElementTypeNavigationBar/XCUIElementTypeButton").Click(); }
public new void OneTimeSetup() { eyes_ = new Eyes(); eyes_.MatchTimeout = TimeSpan.FromSeconds(10); eyes_.Batch = TestDataProvider.BatchInfo; eyes_.SaveNewTests = false; driver_ = InitMobileDriverOnSauceLabs(); IWebElement button = driver_.FindElement(buttonSelector_); button.Click(); eyes_.CutProvider = cutProvider_; }
public void ByIosUIAutomationTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo("POST", "/element", new Dictionary <string, object> { { "ELEMENT", '5' } }); driver.FindElement(new ByIosUIAutomation(".elements()")); (new ByIosUIAutomation(".elements()")).FindElement(driver); server.clear(); List <object> results = new List <object>(); results.Add(new Dictionary <string, object> { { "ELEMENT", "4" } }); server.respondTo("POST", "/elements", results); driver.FindElements(new ByIosUIAutomation(".elements()")); (new ByIosUIAutomation(".elements()")).FindElements(driver); }
public void ByAccessibilityIdTestCase() { IOSDriver <IWebElement> driver = new IOSDriver <IWebElement>(defaultUri, capabilities); server.respondTo("POST", "/element", new Dictionary <string, object> { { "ELEMENT", '5' } }); driver.FindElement(new ByAccessibilityId(".elements()")); (new ByAccessibilityId(".elements()")).FindElement(driver); server.clear(); List <object> results = new List <object>(); results.Add(new Dictionary <string, object> { { "ELEMENT", "4" } }); server.respondTo("POST", "/elements", results); driver.FindElements(new ByAccessibilityId(".elements()")); (new ByAccessibilityId(".elements()")).FindElements(driver); }
static void Main(string[] args) { Local browserStackLocal = null; AppiumOptions appiumOptions = new AppiumOptions(); // Set your BrowserStack access credentials appiumOptions.AddAdditionalCapability("browserstack.user", userName); appiumOptions.AddAdditionalCapability("browserstack.key", accessKey); // Set URL of the application under test appiumOptions.AddAdditionalCapability("app", "bs://<app_id>"); // Specify device and os_version appiumOptions.AddAdditionalCapability("device", "iPhone 11 Pro"); appiumOptions.AddAdditionalCapability("os_version", "13"); // Set browserstack.local capability as true appiumOptions.AddAdditionalCapability("browserstack.local", "true"); // Specify the platform name appiumOptions.PlatformName = "iOS"; // Set other BrowserStack capabilities appiumOptions.AddAdditionalCapability("project", "First CSharp project"); appiumOptions.AddAdditionalCapability("build", "CSharp iOS local"); appiumOptions.AddAdditionalCapability("name", "local_test"); // if the platform is Windows, enable local testing fropm within the test // for Mac and GNU/Linux, run the local binary manually to enable local testing (see the docs) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && appiumOptions.ToCapabilities().HasCapability("browserstack.local") && appiumOptions.ToCapabilities().GetCapability("browserstack.local").ToString() == "true") { browserStackLocal = new Local(); List <KeyValuePair <string, string> > bsLocalArgs = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("key", accessKey) }; browserStackLocal.start(bsLocalArgs); } // 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"), appiumOptions); //Test case for sample iOS Local app. // If you have uploaded your app, update the test case here. IOSElement testButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until( SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal")) ); testButton.Click(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.TextToBePresentInElementValue(driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")), "Response is: Up and running")); IOSElement resultElement = (IOSElement)driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")); Console.WriteLine(resultElement.Text); //Invoke driver.quit() after the test is done to indicate that the test is completed. driver.Quit(); //Stop the BrowserStack Local binary if (browserStackLocal != null) { browserStackLocal.stop(); } }