Hey guys, I need your support.
I’m writing a test to check the flow of messages in our application. I have already completed the sending side, unfortunately I encountered a problem with the receiving side. The current test code returns me
java.lang.AssertionError: Message foundWitam serdecznie expected [true] but found [false]
Expected :true
Actual :false.
What’s the problem?
There is full code of receiving side:
public class test_inc_msg_motoE4 {
public AndroidDriver<MobileElement> driver;
public WebDriverWait wait;
@BeforeMethod
public void setUp() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Moto E (4)");
caps.setCapability("udid", "ZY32298P3K");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "7.1.1");
caps.setCapability("skipUnlock", "true");
caps.setCapability("appPackage", "com.android.settings");
caps.setCapability("appActivity", "com.android.settings.Settings");
caps.setCapability("noReset", true);
driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
wait = new WebDriverWait(driver, 10);
}
private String settingsAppPackageName="some.app";
private String settingsAppActivityName="org.thoughtcrime.securesms.ConversationListActivity";
private String MessageToSend = "abcd";
private String msgFound = "Message found";
private String msgNotFound = "Message not found";
@Test
public void IncomingMsg () throws InterruptedException {
driver.openNotifications();
WebElement msg = driver.findElement(By.xpath("//*[@text='develop test and']"));
boolean msgExists = msg.isDisplayed();
if(msgExists == true) {
driver.navigate().back();
driver.startActivity(new Activity(settingsAppPackageName, settingsAppActivityName));
driver.findElementByXPath("//*[@text='develop test and']").click();
List<MobileElement> list = driver.findElementsById("some.app:id/body_bubble");
boolean hasMatchedElement = false;
for (MobileElement item : list) {
if (item.getText().equals(MessageToSend)) {
hasMatchedElement = true;
}
}
Assert.assertTrue(hasMatchedElement, msgFound + MessageToSend);
driver.closeApp();
} else {
Assert.assertFalse(false, msgNotFound);
}
}
@AfterMethod
public void teardown(){
driver.quit();
}
}