public void testSearchIFixitOnHomeScreen() { Console.WriteLine("should allow to search iFixit on Home screen"); /* * Steps: * 1. Reopen iFixit app * 2. Click Search menu on the left menu bar * 3. Search keyword 'Macbook Pro 2015' * 4. Press Enter button on keyboard * * Expected: It should show at least 33 results. * * 5. Clear the current content * 6. Search keyword 'Acura' on Categories tab * * Expected: It should show at least 6 results. */ driver.LaunchApp(); Thread.Sleep(5000); driver.FindElementByXPath("//XCUIElementTypeButton[@name='START A REPAIR']").Click(); Thread.Sleep(2000); driver.FindElementByXPath("//*[@name='Search']").Click(); driver.FindElementByXPath("//XCUIElementTypeSearchField[@name='Search']").SendKeys("Macbook Pro 2015"); Thread.Sleep(2000); IList <IWebElement> firstResult = driver.FindElementsByXPath("//XCUIElementTypeStaticText[contains(@label,'MacBook Pro')]"); driver.FindElementByXPath("//XCUIElementTypeButton[@name='Cancel']").Click(); driver.FindElementByXPath("//*[@name='Search']").Click(); driver.FindElementByXPath("//XCUIElementTypeSearchField[@name='Search']").SendKeys("Acura"); driver.FindElementByXPath("//XCUIElementTypeButton[@name='Categories']").Click(); Thread.Sleep(2000); IList <IWebElement> secondResult = driver.FindElementsByXPath("//XCUIElementTypeStaticText[contains(@label,'Acura')]"); Assert.IsTrue(firstResult.Count >= 34, "The expected results are greater or equal to 33 results."); Assert.IsTrue(secondResult.Count >= 6, "The expected results are greater or equal to 6 results."); }
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 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 FullScenario() { // Read the current local time SwitchToWorldClockTab(); string localTimeText = ReadLocalTime(); Assert.IsTrue(localTimeText.Length > 0); // Add an alarm at 1 minute after local time SwitchToAlarmTab(); AddAlarm(localTimeText); var alarmEntries = AlarmClockSession.FindElementsByXPath(string.Format("//ListItem[starts-with(@Name, \"{0}\")]", NewAlarmName)); Assert.IsTrue(alarmEntries.Count > 0); // Try to dismiss notification after 1 minute System.Threading.Thread.Sleep(60000); DismissNotification(); }
public override IEnumerable <IOSElement> FindAllElements(IOSDriver <IOSElement> searchContext) { return(searchContext.FindElementsByXPath(_locatorValue)); }
public void TestShouldFindElementsByXPath() { ICollection <IOSElement> elements = driver.FindElementsByXPath("//XCUIElementTypeWindow//XCUIElementTypeButton"); Assert.AreEqual(8, elements.Count); }