approve 'add testbaidu.java'

approve 'add testbaidu.java'
main
20220007 1 year ago
commit 020db93b59

@ -0,0 +1,51 @@
package com.hogwarts.webui;
import com.hogwarts.base.*;
import org.apache.log4j.Logger;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
public class TestBaiDu extends WebUIBase {
private Logger logger = Logger.getLogger(TestBaiDu.class);
@Test
public void baiduSearch1() throws Exception{
String checkString = "今日头条";
baiduSearch(checkString);
}
@Test
public void baiduSearch2() throws Exception{
String checkString = "王者荣耀";
baiduSearch(checkString);
}
/**
*
*
* @param checkString
* @throws Exception
*/
public void baiduSearch(String checkString) throws Exception {
testcaseName = "Baidu search UI automation test.";
logger.info("Start the automation test: " + testcaseName);
//浏览器中打开百度
logger.info("Open the www.baidu.com");
navigation.to("http://www.baidu.com");
wait5s();
//输入搜索内容Selenium
WebUITasks.inputText(checkString,driver);
wait5s();
//单击搜索按钮
WebUITasks.clickSearchBtn(driver);
wait5s();
String browserTitle = driver.getTitle();
Assertions.assertTrue(browserTitle.contains(checkString) || browserTitle.contains("安全验证")
, "Check if the web page contains the key word " + checkString + "");
}
}
Loading…
Cancel
Save