Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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