Skip to content

Instantly share code, notes, and snippets.

@trivial-search
Created June 11, 2018 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trivial-search/a8d5ea9a022fdf098d3b29e754a7fb24 to your computer and use it in GitHub Desktop.
Save trivial-search/a8d5ea9a022fdf098d3b29e754a7fb24 to your computer and use it in GitHub Desktop.
[Test()]
public void TradeMe_verify_logged_in()
{
// Find the login input field
AppiumWebElement TradeMe_Login = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginEmail");
// key in your user name
TradeMe_Login.SendKeys("xxxxxxx@gmail.com");
// Find the password field
AppiumWebElement TradeMe_Pwd = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginPassword");
// key in the password
TradeMe_Pwd.SendKeys("xxxxxxxx");
// Find the login button
AppiumWebElement Login_Button = app.FindElementById("nz.co.trademe.trademe:id/buttonLogin");
// Tap the login button
Login_Button.Tap(1, 1);
// Wait for the account menu item to be displayed
WebDriverWait wait = new WebDriverWait(app, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/menuAccount")));
// Find icon for my account
AppiumWebElement account_icon = app.FindElementByAccessibilityId("Account");
// tap the icon
account_icon.Tap(1, 1);
// confirm that the logout button is visible, this is in turn ensure that the user name isbeing displayed
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/buttonLogout")));
// find and assert on the text of the user name
AppiumWebElement account_name = app.FindElementById("nz.co.trademe.trademe:id/textViewAboutMemberUsername");
Assert.AreEqual(account_name.Text, "xxxxxx");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment