介紹
WebUI自動(dòng)化測試框架phoenix.webui.framework發(fā)布20170610版本。
本次發(fā)布修正了一些bug,更多Isseus信息請(qǐng)?jiān)L問Github。添加的主要功能如下:
增加了通過注解的方式來配置PageObject(頁面對(duì)象)先匪,單元測試代碼如下(本文所有的代碼都可以在Github項(xiàng)目中獲取):
<code java>
package org.suren.autotest.web.framework.page;
import org.suren.autotest.web.framework.annotation.AutoDataSource;
import org.suren.autotest.web.framework.annotation.AutoLocator;
import org.suren.autotest.web.framework.annotation.AutoPage;
import org.suren.autotest.web.framework.annotation.AutoStrategy;
import org.suren.autotest.web.framework.core.LocatorType;
import org.suren.autotest.web.framework.core.StrategyType;
import org.suren.autotest.web.framework.core.ui.Button;
import org.suren.autotest.web.framework.core.ui.Text;
/**
使用注解的示例Page類
@author suren
-
@date 2017年6月7日 下午7:10:40
*/
@AutoPage(url = "http://maimai.cn/")
@AutoDataSource(name = "data", resource = "dataSource/xml/user_data_anno.xml")
public class AnnotationPage extends Page
{
@AutoStrategy(type = StrategyType.PRIORITY)
@AutoLocator(locator = LocatorType.BY_PARTIAL_LINK_TEXT, value = "實(shí)名動(dòng)態(tài)")
private Button toLoginBut;@AutoLocator(locator = LocatorType.BY_XPATH, value = "http://input[@placeholder='請(qǐng)輸入手機(jī)號(hào)碼/脈脈號(hào)']")
private Text phoneText;public Button getToLoginBut() {
return toLoginBut;
}public void setToLoginBut(Button toLoginBut) {
this.toLoginBut = toLoginBut;
}public Text getPhoneText() {
return phoneText;
}public void setPhoneText(Text phoneText) {
this.phoneText = phoneText;
}
}
</code>
測試代碼如下:
<code java>
package org.suren.autotest.web.framework.util;
import org.junit.*;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.suren.autotest.web.framework.IgnoreReasonConstants;
import org.suren.autotest.web.framework.page.AnnotationPage;
import org.suren.autotest.web.framework.settings.DriverConstants;
import org.suren.autotest.web.framework.settings.SettingUtil;
import java.io.IOException;
/**
測試使用注解配置的方式
@author suren
-
@date 2017年6月7日 下午7:10:12
*/
@Configuration
@ComponentScan(basePackages = "org.suren.autotest.web.webframework.page")
public class AutoAnnotationTest
{
private SettingUtil util;@Before
public void setUp()
{
util = new SettingUtil();
}@Test
public void basicTest()
{
util.getEngine().setDriverStr(DriverConstants.DRIVER_HTML_UNIT);
util.getEngine().init();AnnotationPage page = util.getPage(AnnotationPage.class); Assert.assertNotNull(page); Assert.assertNotNull(page.getUrl()); Assert.assertNotNull(page.getToLoginBut()); page.open(); page.getToLoginBut().click();
}
@Test
@Ignore(value = IgnoreReasonConstants.REAL_BROWSER)
public void realTest()
{
util.getEngine().setDriverStr(DriverConstants.DRIVER_CHROME);
util.getEngine().init();
util.initData();AnnotationPage page = util.getPage(AnnotationPage.class); page.open(); page.getToLoginBut().click(); page.getPhoneText().fillNotBlankValue(); ThreadUtil.silentSleep(3000);
}
@After
public void tearDown() throws IOException
{
util.close();
}
}
</code>
期待更多更好用的功能請(qǐng)您持續(xù)關(guān)注本項(xiàng)目假颇。支持開源胚鸯,支持中國開源項(xiàng)目!1考Α姜钳!
?參考
本文為原創(chuàng)坦冠,如果您當(dāng)前訪問的域名不是surenpi.com,請(qǐng)?jiān)L問“素人派”哥桥。