android UiAutomator聊天室用例中斷言的應用

本人最近在學習UiAutomator的時候,寫一個聊天室的用例,剛好練習一下斷言的應用。分享出來,供大家參考。

	//班級聊天測試
	public void charroomSendAndSwitchSwitch() throws UiObjectNotFoundException {
		login();
		waitForTextAndClick("聊天");
		waitForTextAndClick("班級羣聊");
		String text = "我是測試!"+getNow();
		writeText(text);
		waitForTextAndClick("發送");
		assertTrue(getUiObjectByText(text).exists());
		//驗證切換老師按鈕
		waitForResourceIdAndClick("com.gaotu100.superclass:id/chatroom_header_filter_msg_image");//點擊切換老師按鈕
		assertFalse(getUiObjectByText(text).exists());
		waitForResourceIdAndClick("com.gaotu100.superclass:id/chatroom_header_filter_msg_image");//點擊切換老師按鈕
		assertTrue(getUiObjectByText(text).exists());
		}
中間有一個切換老師的按鈕,點擊之後就只能看到老師的發言。不能看到自己的發言了。下面是login()方法。

	//登錄學生app
	public void login() throws UiObjectNotFoundException {
		waitForResourceIdAndClick("com.gaotu100.superclass:id/view_shared_tabbar_me");//點擊我的
		if (!getUiObjectByText("我的班課").exists()) {
			pressTimes(KeyEvent.KEYCODE_FORWARD_DEL, 12);//清除已有帳號
			getUiObjectByResourceId("com.gaotu100.superclass:id/login_username").setText("1320454218");//輸入帳號
			getUiObjectByResourceId("com.gaotu100.superclass:id/login_password").setText("qqqqqq");//輸入密碼
			getUiObjectByResourceId("com.gaotu100.superclass:id/login_button").clickAndWaitForNewWindow();//點擊登錄
			}
		}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章