import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class NaukriAppTest {
private AndroidDriver<MobileElement> driver;
@BeforeMethod
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Android Device");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.naukri.fragement");
capabilities.setCapability("appActivity", "com.naukri.fragement.NaukriSplashScreen");
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@Test
public void testNaukriApp() {
// Find and click the 'Login' button
MobileElement loginButton = driver.findElementById("com.naukri.fragement:id/naukri_login");
loginButton.click();
// Enter username and password
MobileElement username = driver.findElementById("com.naukri.fragement:id/username");
username.sendKeys("your_username");
MobileElement password = driver.findElementById("com.naukri.fragement:id/password");
password.sendKeys("your_password");
// Find and click the 'Sign In' button
MobileElement signInButton = driver.findElementById("com.naukri.fragement:id/login");
signInButton.click();
// Verify if the user is logged in successfully
MobileElement profile = driver.findElementById("com.naukri.fragement:id/myProfile");
assert profile.isDisplayed();
}
@AfterMethod
public void tearDown() {
driver.quit();
}
}
No comments:
Post a Comment