The support of phoenixframework automated testing platform for Safari browser

The phoenixframework automated test platform can support the Safari browser very well, but the following steps are required to configure the browser:

test environment

操作系统:Mac OS X 10.11

Safari版本:9.0(11601.1.56)

1. Safari extension download

Download the Safari extension. Due to the faster version update, here are two download addresses:

(1) Download from the network disk of the platform, the address is as follows: http://pan.baidu.com/s/1dFkGfPv

Download filename: SafariDriver.safariextz

(2) Download from selenium official website: http://docs.seleniumhq.org/download/,

2. Safari extension installation

After downloading, double-click the file and click Trust to install the extension. The result is as follows:

3. Safari browser test

Execute the following code in the Phoenix_develop project:

package org.phoenix.cases;

import java.util.HashMap;
import java.util.LinkedList;

import org.phoenix.enums.LocatorType;
import org.phoenix.model.CaseLogBean;
import org.phoenix.model.InterfaceBatchDataBean;
import org.phoenix.model.UnitLogBean;
import org.phoenix.proxy.ActionProxy;

/**
 * Safari浏览器驱动测试类
 * @author mengfeiyang
 *
 */
public class TestBrowserDriver extends ActionProxy{
	private static String caseName = "Safari测试用例";
	
	public TestBrowserDriver() {
		
	}

	@Override
	public LinkedList<UnitLogBean> run(CaseLogBean caseLogBean) {
		init(caseLogBean);
		phoenix.webAPI().openNewWindowBySafari("http://www.baidu.com");

		phoenix.webAPI().webElement("//*[@id=\"kw\"]",LocatorType.XPATH).setText("phoenixframe");
		phoenix.webAPI().webElement("//*[@id=\"su\"]", LocatorType.XPATH).click();
		String r = phoenix.webAPI().webElement("//*[@id=\"su\"]", LocatorType.XPATH).getAttribute("value");
		phoenix.checkPoint().checkIsEqual(r, "百度一下");
		phoenix.commonAPI().addLog("我是自定义的");
		phoenix.webAPI().sleep(1000);
		phoenix.webAPI().closeWindow();	
		
		return getUnitLog();
	}
	
	public static void main(String[] args) {
		LinkedList<UnitLogBean> ll = new TestBrowserDriver().run(new CaseLogBean());
		for(UnitLogBean l : ll){
			System.out.println(l.getContent());
		}
	}
}

4. Execution results

2016-07-23 16:05:17 INFO [main] (PhoenixLogger.java:46) - 步骤 [ closeWindow ]执行成功,参数值:null,执行结果返回值:null
步骤 [ setWebProxy ]执行成功,参数值:[org.phoenix.api.impl.WebAPI@7a4f0b5b],执行结果返回值:null
Android方法 [setAndroidAPIProxy] 执行通过,相关参数:[org.phoenix.api.impl.AndroidAppAPI@46abb50a]
步骤 [ openNewWindowBySafari ]执行成功,参数值:[http://www.baidu.com],执行结果返回值:null
步骤 [ setText ]执行成功,参数值:[phoenixframe],执行结果返回值:null
步骤 [ click ]执行成功,参数值:null,执行结果返回值:null
步骤 [ getAttribute ]执行成功,参数值:[value],执行结果返回值:百度一下
检查点 [checkIsEqual] 执行通过,相关参数:[百度一下, 百度一下]
自定义步骤 [ addLog ] 执行成功,参数值:[ 我是自定义的 ]
步骤 [ sleep ]执行成功,参数值:[1000],执行结果返回值:null
步骤 [ closeWindow ]执行成功,参数值:null,执行结果返回值:null

Safari driver configuration is complete.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324074393&siteId=291194637
Recommended