-
-
Save Tarek-O/81552f455712c9e2ecc58e37aab7ad81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pageObjects; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.support.PageFactory; | |
import io.appium.java_client.pagefactory.AndroidFindBy; | |
import io.appium.java_client.pagefactory.AppiumFieldDecorator; | |
import util.hook; | |
public class explorePage { | |
public explorePage() { | |
PageFactory.initElements(new AppiumFieldDecorator(hook.getDriver()), this); | |
} | |
@AndroidFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/androidx.cardview.widget.CardView/android.view.ViewGroup/android.widget.TextView") | |
public WebElement loginButton; | |
public WebElement getLoginButton() { | |
return hook.getDriver().findElement(By.xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/androidx.cardview.widget.CardView/android.view.ViewGroup/android.widget.TextView")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.concurrent.TimeUnit; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import io.appium.java_client.android.AndroidDriver; | |
import io.appium.java_client.remote.MobileCapabilityType; | |
import io.cucumber.java.After; | |
import io.cucumber.java.Before; | |
public class hook { | |
private static WebDriver driver; | |
@Before | |
public void setUpAndroidAppium() throws MalformedURLException{ | |
DesiredCapabilities cap = new DesiredCapabilities(); | |
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "android"); | |
cap.setCapability("fullReset", false); | |
cap.setCapability("automationName", "UiAutomator2"); | |
//cap.setCapability("appWaitActivity", ""); | |
cap.setCapability(MobileCapabilityType.APP, System.getProperty("user.dir")+"//App//FILENAME.apk"); | |
driver = new AndroidDriver<WebElement>(new URL("http://0.0.0.0:4723/wd/hub"), cap); | |
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); | |
} | |
@After | |
public void tearDown() | |
{ | |
driver.quit(); | |
} | |
public static WebDriver getDriver() | |
{ | |
return driver; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package stepDefinitions; | |
import org.openqa.selenium.WebDriver; | |
import io.cucumber.java.en.Given; | |
import io.cucumber.java.en.Then; | |
import io.cucumber.java.en.When; | |
import pageObjects.explorePage; | |
import pageObjects.onBoardingPage; | |
import util.hook; | |
public class testDef { | |
private WebDriver driver; | |
public explorePage explorePage = new explorePage(); | |
public onBoardingPage onBoardingPage = new onBoardingPage(); | |
public testDef() { | |
this.driver = hook.getDriver(); | |
} | |
@Given("the Login button is clicked from the Dashboard") | |
public void the_login_button_is_clicked_from_the_dashboard() { | |
//WebElement englishBtn = onBoardingPage.onBoardingEnglish; | |
//assertTrue(englishBtn.isDisplayed()); | |
//englishBtn.click(); | |
onBoardingPage.selectEnglish(); | |
} | |
@When("a valid mobile line {int} and password {string} is submitted") | |
public void a_valid_mobile_line_and_password_is_submitted(Integer int1, String string) { | |
// Write code here that turns the phrase above into concrete actions | |
} | |
@Then("the user should be successfully logged in") | |
public void the_user_should_be_successfully_logged_in() { | |
// Write code here that turns the phrase above into concrete actions | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment