Use of Assert statement in Appium C #
string Dashboardtext = BBElement.DashBoardValidation.Text;
- We can use Assert functionality to verify the text or verify the element in wave page or mobile page.
- It works like in run time we have to get the text and have to verify with actual text.
- We have to import "using NUnit.Framework;" to access Assert functionalities.
Below Example with BigBasket:
using Appium_Automation.TestData;
using OpenQA.Selenium;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using System.Threading;
namespace Appium_Automation.TestCases
{
public class LoginApp
{
BigBasketElements BBElement = new BigBasketElements();
void HomepageLogin()
{
AppiumDriver<AndroidElement> driver;
string app = "C:\\Users\\105798\\testapplications\\HealthifyMe.apk";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("deviceName", "emulator-5554");
capabilities.SetCapability(CapabilityType.Version, "6.0");
capabilities.SetCapability(CapabilityType.BrowserName, "Android");
capabilities.SetCapability(CapabilityType.Platform, "Android");
capabilities.SetCapability("appPackage", "com.healthifyme.basic");
capabilities.SetCapability("appActivity", "com.healthifyme.basic.activities.NewLoginSignupActivity");
capabilities.SetCapability("NEW_COMAND_TIMEOUT", "50000");
capabilities.SetCapability("app", "C:\\Users\\105798\\testapplications\\HealthifyMe.apk");
Thread.Sleep(2000);
driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.Sleep(25000);
PageFactory.InitElements(driver, BBElement);
BBElement.LoginHomepage.Click();
BBElement.EmailField.SendKeys("xxxxxx@gmail.com");
BBElement.PasswordField.SendKeys("xxxxxxx");
driver.Navigate().Back();
BBElement.LoginButton.Click();
Thread.Sleep(20000);
// Home Page Validation
string Dashboardtext = BBElement.DashBoardValidation.Text;
Console.WriteLine(Dashboardtext);
Assert.AreEqual("Shop By Category", Dashboardtext);
Thread.Sleep(5000);
Accessing elements from different class where am using Page factory.For more details please have a look on below link
http://www.qalearningguide.com/2017/02/appium-with-c-session-5-page-object.html
Accessing elements from different class where am using Page factory.For more details please have a look on below link
http://www.qalearningguide.com/2017/02/appium-with-c-session-5-page-object.html