この記事では主に、Springframeworkを使用してAppiumのDriver呼び出しを最適化し、コードに書かれた多数の設定パラメータを設定ファイルに定義し、またAndroidDriverを呼び出すか、または呼び出すかを柔軟に制御する方法について説明します。 IOSドライバー。
Spring環境はご自身で構築してください。
次の使用例は、spring4.3、appium Java クライアント 4.1.2、selenium 3.0.1 に基づいています
まず、ドライバーを作成し、AndroidDriver と IOSDriver の作成に関連するいくつかの Bean プロパティを定義します。次に、Driver
package test; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.openqa.selenium.remote.DesiredCapabilities; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import io.appium.java_client.MobileElement; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.ios.IOSDriver; @Component @Scope("prototype") public class Driver { private List<ArrayList<String>> capabilityList; private DesiredCapabilities capabilities; private URL url; private AndroidDriver<MobileElement> androidDriver; private IOSDriver<MobileElement> iOSDriver; public List<ArrayList<String>> getCapabilityList() { return capabilityList; } public void setCapabilityList(List<ArrayList<String>> capabilityList) { this.capabilityList = capabilityList; } public DesiredCapabilities getCapabilities() { return capabilities; } public void setCapabilities(DesiredCapabilities capabilities) { this.capabilities = capabilities; } public URL getUrl() { return url; } public void setUrl(URL url) { this.url = url; } public AndroidDriver<MobileElement> getAndroidDriver() { return androidDriver; } public void setAndroidDriver(AndroidDriver<MobileElement> androidDriver) { this.androidDriver = androidDriver; } public IOSDriver<MobileElement> getiOSDriver() { return iOSDriver; } public void setiOSDriver(IOSDriver<MobileElement> iOSDriver) { this.iOSDriver = iOSDriver; } }
を初期化して閉じるためのDriverAdaptorを作成します。次に、Spring構成ファイルを作成します:
package test; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import org.openqa.selenium.remote.DesiredCapabilities; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; import io.appium.java_client.MobileElement; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.ios.IOSDriver; @Component public class DriverAdaptor { private AndroidDriver<MobileElement> androidDriver = null; private IOSDriver<MobileElement> iOSDriver = null; @Resource private Driver driver; public Driver getDriver() { return driver; } public void setDriver(Driver driver) { this.driver = driver; } @Resource ApplicationContext ctx; @Value("#{baseconfig.environment}") String environment; @SuppressWarnings("unchecked") public void initAndroidDriverByConfigFile() throws Exception { for (ArrayList<String> arg : (List<ArrayList<String>>) ctx.getBean(environment)) { ctx.getBean("capabilities", DesiredCapabilities.class).setCapability(arg.get(0), arg.get(1)); } androidDriver = new AndroidDriver<>(driver.getUrl(), driver.getCapabilities()); driver.setAndroidDriver(androidDriver); } public void quitAndoridSession() { if (androidDriver != null) androidDriver.quit(); } @SuppressWarnings("unchecked") public void initIOSDriverByConfigFile() throws Exception { for (ArrayList<String> arg : (List<ArrayList<String>>) ctx.getBean(environment)) { ctx.getBean("capabilities", DesiredCapabilities.class).setCapability(arg.get(0), arg.get(1)); } iOSDriver = new IOSDriver<>(driver.getUrl(), driver.getCapabilities()); driver.setiOSDriver(iOSDriver); } public void quitIOSService() { if (iOSDriver != null) iOSDriver.quit(); } }
この構成ファイルでは、AndroidとIOSの関連構成を保存するために使用される2つの.propertiesを定義します
。 3 番目の構成ファイルは、
を使用して、ロードする構成ファイルを取得します
.properties 構成ファイルは次のとおりです:
android.properties ここでは、WeChat
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd"> <!-- 组件扫描 --> <context:component-scan base-package="test"></context:component-scan> <!-- aspect --> <aop:aspectj-autoproxy proxy-target-class="false" /> <!-- 定义配置文件properties --> <util:properties id="android" location="classpath:android.properties" /> <util:properties id="ios" location="classpath:ios.properties" /> <util:properties id="baseconfig" location="classpath:baseconfig.properties" /> <!-- Android --> <util:list id="androidCapabilityList"> <list> <value>platformName</value> <value>#{android.platformName}</value> </list> <list> <value>deviceName</value> <value>#{android.deviceName}</value> </list> <list> <value>platformVersion</value> <value>#{android.platformVersion}</value> </list> <list> <value>appPackage</value> <value>#{android.appPackage}</value> </list> <list> <value>appActivity</value> <value>#{android.appActivity}</value> </list> </util:list> <!-- IOS --> <util:list id="iOScapabilityList"> <list> <value>platformName</value> <value>#{ios.platformName}</value> </list> <list> <value>deviceName</value> <value>#{ios.deviceName}</value> </list> <list> <value>automationName</value> <value>#{ios.automationName}</value> </list> <list> <value>platformVersion</value> <value>#{ios.platformVersion}</value> </list> <list> <value>app</value> <value>#{ios.app}</value> </list> </util:list> <!-- appium driver --> <bean id="url" class="java.net.URL"> <constructor-arg index="0" value="#{baseconfig.url}"></constructor-arg> </bean> <bean id="capabilities" class="org.openqa.selenium.remote.DesiredCapabilities"></bean> <bean id="driver" class="test.Driver"> <property name="capabilityList" ref="#{baseconfig.environment}"></property> <property name="capabilities" ref="capabilities"></property> <property name="url" ref="url"></property> </bean> </beans>
ios.properties .app の呼び出しをシミュレートします。パスは自分で設定してください
#APPium Android Driver platformName:Android deviceName:HUAWEIP8 platformVersion:6.0 # wechat appPackage:com.tencent.mm appActivity:.ui.LauncherUI
baseconfig.properties
#APPium IOS Driver platformName:iOS deviceName:iPhone Simulator automationName:XCUITest platformVersion:10.2 app:/X/X/X.app
最後に、テスト クラスを作成して、それが機能するかどうかを確認します。呼び出し可能
environment:androidCapabilityList # Driver url url:http://127.0.0.1:4723/wd/hub
テストメソッドには遅延のみが含まれています。WeChat を呼び出すことができれば、プロセスは成功したことを意味します。
以上がSPRING に基づく APPIUM 構成アプリケーションの詳細な紹介の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

この記事では、Javaプロジェクト管理、自動化の構築、依存関係の解像度にMavenとGradleを使用して、アプローチと最適化戦略を比較して説明します。

この記事では、MavenやGradleなどのツールを使用して、適切なバージョン化と依存関係管理を使用して、カスタムJavaライブラリ(JARファイル)の作成と使用について説明します。

この記事では、カフェインとグアバキャッシュを使用してJavaでマルチレベルキャッシュを実装してアプリケーションのパフォーマンスを向上させています。セットアップ、統合、パフォーマンスの利点をカバーし、構成と立ち退きポリシー管理Best Pra

この記事では、キャッシュや怠zyなロードなどの高度な機能を備えたオブジェクトリレーショナルマッピングにJPAを使用することについて説明します。潜在的な落とし穴を強調しながら、パフォーマンスを最適化するためのセットアップ、エンティティマッピング、およびベストプラクティスをカバーしています。[159文字]

Javaのクラスロードには、ブートストラップ、拡張機能、およびアプリケーションクラスローダーを備えた階層システムを使用して、クラスの読み込み、リンク、および初期化が含まれます。親の委任モデルは、コアクラスが最初にロードされ、カスタムクラスのLOAに影響を与えることを保証します


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

SublimeText3 中国語版
中国語版、とても使いやすい

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

SecLists
SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

Dreamweaver Mac版
ビジュアル Web 開発ツール

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール
