溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

PhoenixAutotest怎么使用

發(fā)布時間:2022-02-19 15:18:26 來源:億速云 閱讀:159 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要介紹了PhoenixAutotest怎么使用的相關(guān)知識,內(nèi)容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇PhoenixAutotest怎么使用文章都會有所收獲,下面我們一起來看看吧。

PhoenixAutoTest是一個基于 Selenium 的Web自動測試框架,通過該框架可以簡化測試人員的學(xué)習(xí)難度,只要 編寫少量的Java代碼即可,大多數(shù)的工作都是編寫頁面元素的描述文件以及對應(yīng)的數(shù)據(jù)源。

PhoenixAutotest怎么使用

介紹

WebUI自動化測試框架phoenix.webui.framework發(fā)布20170610版本。

增加了通過注解的方式來配置PageObject(頁面對象),單元測試代碼如下:

/*
*
*  * Copyright 2002-2007 the original author or authors.
*  *
*  * Licensed under the Apache License, Version 2.0 (the "License");
*  * you may not use this file except in compliance with the License.
*  * You may obtain a copy of the License at
*  *
*  *      http://www.apache.org/licenses/LICENSE-2.0
*  *
*  * Unless required by applicable law or agreed to in writing, software
*  * distributed under the License is distributed on an "AS IS" BASIS,
*  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  * See the License for the specific language governing permissions and
*  * limitations under the License.
*
*/

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 = "實名動態(tài)")
private Button toLoginBut;

@AutoLocator(locator = LocatorType.BY_XPATH, value = "//input[@placeholder='請輸入手機號碼/脈脈號']")
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;
}
}

測試代碼如下:

/*
*
*  * Copyright 2002-2007 the original author or authors.
*  *
*  * Licensed under the Apache License, Version 2.0 (the "License");
*  * you may not use this file except in compliance with the License.
*  * You may obtain a copy of the License at
*  *
*  *      http://www.apache.org/licenses/LICENSE-2.0
*  *
*  * Unless required by applicable law or agreed to in writing, software
*  * distributed under the License is distributed on an "AS IS" BASIS,
*  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  * See the License for the specific language governing permissions and
*  * limitations under the License.
*
*/

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();
}
}

關(guān)于“PhoenixAutotest怎么使用”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“PhoenixAutotest怎么使用”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI