Application Screen Shot我正在测试一个安卓应用的登录场景。我有7个不同的测试用例,我已经写了代码,但它给出了错误请检查我的代码和错误,让我知道,我在哪里出错。
我只试过这段代码
package TestCases.Project_Entry;
import java.io.IOException;
import java.net.MalformedURLException;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.*;
import PageObject.loginObjects;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
public class loginTestCases extends launch {
@BeforeTest
public void openapp() throws MalformedURLException {
capabilities();
}
@Test
public void CodeAndPasswordBlank() {
loginObjects log = new loginObjects(driver);
log.Login.click();
String ToastMessage1 = driver.findElement(By.xpath("//android.widget.Toast")).getAttribute("name");
System.out.println(ToastMessage1);
Assert.assertEquals(ToastMessage1, "can't be blank!");
}
@Test
public void CodeBlankPasswordCorrect() {
loginObjects log = new loginObjects(driver);
log.Password.sendKeys("111111");
log.Login.click();
String ToastMessage2 = driver.findElement(By.xpath("//android.widget.Toast")).getAttribute("name");
System.out.println(ToastMessage2);
Assert.assertEquals(ToastMessage2, "can't be blank!");
}
@Test
public void CodeCorrectPasswordBlank() {
loginObjects log = new loginObjects(driver);
log.Code.sendKeys("111111");
log.Login.click();
String ToastMessage3 = driver.findElement(By.xpath("//android.widget.Toast")).getAttribute("name");
System.out.println(ToastMessage3);
Assert.assertEquals(ToastMessage3, "can't be blank!");
}
@Test
public void CodeIncorrectPasswordCorrect() {
loginObjects log = new loginObjects(driver);
log.Code.sendKeys("111112");
log.Password.sendKeys("111111");
log.Login.click();
String ToastMessage4 = driver.findElement(By.xpath("//android.widget.Toast")).getAttribute("name");
System.out.println(ToastMessage4);
Assert.assertEquals(ToastMessage4, "Invalid login!");
}
@Test
public void CodeCorrectPasswordInorrect() {
loginObjects log = new loginObjects(driver);
log.Code.sendKeys("111111");
log.Password.sendKeys("123456");
log.Login.click();
String ToastMessage5 = driver.findElement(By.xpath("//android.widget.Toast")).getAttribute("name");
System.out.println(ToastMessage5);
Assert.assertEquals(ToastMessage5, "Invalid login!");
}
@Test
public void CodeInCorrectPasswordInorrect() {
loginObjects log = new loginObjects(driver);
log.Code.sendKeys("111211");
log.Password.sendKeys("123456");
log.Login.click();
String ToastMessage6 = driver.findElement(By.xpath("//android.widget.Toast")).getAttribute("name");
System.out.println(ToastMessage6);
Assert.assertEquals(ToastMessage6, "Invalid login!");
}
@Test
public void CodeCorrectPasswordCorrect() {
loginObjects log = new loginObjects(driver);
log.Code.sendKeys("111111");
log.Password.sendKeys("111111");
log.Login.click();
AndroidElement SelectGroup = driver.findElement(By.id("android:id/alertTitle"));
SelectGroup.isDisplayed();
}
}只有这两个人能通过。
通过: CodeAndPasswordBlank通过: CodeBlankPasswordCorrect
发布于 2019-09-05 11:34:01
我想这里没有触摸到弹出键盘的输入栏。在输入数字之前,您应该通过单击输入字段上的()来调用键盘。因此,请检查并上传截图,以便更好地帮助您
发布于 2019-09-05 17:24:28
实际上我得到了问题所在。在每次测试之前,我需要检查代码和密码字段是否已经有一些东西,然后我需要检查它,清除它,然后进一步移动。请让我知道我们如何才能在每次测试之前检查这个。
https://stackoverflow.com/questions/57789176
复制相似问题