简体   繁体   English

在Java for iOS中使用高跟鞋类进行的每项测试之前,如何使Appium和应用程序自动启动?

[英]How can I make Appium and the app launch automatically before every test in Java for iOS with heels classes?

Now that I am able to open Appium and then running a script launching the app on a simulator, How can I launch Appium and the app before every test? 现在,我能够打开Appium,然后运行脚本以在模拟器上启动该应用程序,如何在每次测试之前启动Appium和该应用程序? How can this be made with helper classes that are called on the test scripts? 如何通过在测试脚本上调用的帮助程序类来做到这一点?

Not much familiar with java but there is @beforeTest @beforeSuite annotations in Testng, which might be worth to look on. 对Java不太熟悉,但是Testng中有@beforeTest @beforeSuite批注,可能值得一看。 Here is a helping link 这是一个帮助链接

https://examples.javacodegeeks.com/enterprise-java/testng/testng-beforesuite-example/ https://examples.javacodegeeks.com/enterprise-java/testng/testng-beforesuite-example/

Write one base class and write your code to launch the app inside the constructor of base class. 编写一个基类并编写代码以在基类的构造函数中启动应用程序。

And then extend the base class to all your test classes. 然后将基类扩展到所有测试类。 The base class constructor will be called automatically before the child class is executed. 在执行子类之前,将自动调用基类的构造函数。

Hope this helps :) 希望这可以帮助 :)

You have to create your appium server with --override-session flag. 您必须使用--override-session标志创建您的appium服务器。

node main.js --override-session

And then for each session you have to creare a new driver... 然后,对于每个会话,您都必须创建一个新的驱动程序...

driver = new AndroidDriver<WebElement>(new URL("http://192.168.1.50:4723/wd/hub"), capabilities);
//1. start doing things here...
//1. end
//Launch app again
driver = new AndroidDriver<WebElement>(new URL("http://192.168.1.50:4723/wd/hub"), capabilities);
//2. start doing things here...
//2. end
...

Ok so I've searched separately for the 2 things I needed here. 好的,所以我在这里分别搜索了我需要的两件事。 one is the launching of the Appium with Java code and found this: 一种是使用Java代码启动Appium,并发现了这一点:

@Before public void setup() throws Exception { @在公共void setup()抛出异常之前,{

    service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
            .usingDriverExecutable(new File("/usr/local/bin/node"))
            .withAppiumJS(
                    new File("/usr/local/bin/appium"))
            .withIPAddress("127.0.0.1").usingPort(4723));

    service.start();

Works great. 效果很好。 The second thing I wanted to do is automatically launch Appium and even the app. 我想做的第二件事是自动启动Appium甚至是应用程序。 and this can be done as I've searched tried and saw by @BeforeClass annotation on a separate class, creating static methods with the launch functions and then extending that separate class on the test class. 这可以通过在单独的类上通过@BeforeClass注释搜索尝试并看到的方法来完成,使用启动函数创建静态方法,然后在测试类上扩展该单独的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在方案出现之前使Appium清洁应用 - How to make Appium clean app before scenario Appium iOS:每次测试前退出应用程序 - Appium iOS: Sign out from app before each test 如何在运行应用程序时使其在每次启动时都干净启动? - How can i make my app when running it to start clean on every launch? 如何在 vscode 中设置 launch.json 中的默认 java 配置,以使 vscode 在每次运行应用程序时停止要求我指定主类? - How can I set in vscode a default java configuration in launch.json to make vscode stop asking me to specify a main class every time I run the app? 如何在启动时发现我的 java 代码之前的错误? - How can I find error before my java code at launch? 如何避免在每次测试之前执行注释? - How can I avoid annotations executing before every test? JAVA中的Appium ios应用程序:如何在iOS应用程序的appium中打开键盘视图 - Appium ios app in JAVA : How to open a keyboard view in appium for ios app App Center 上的 Appium 无法在 iOS 和 Android (Java) 之间切换 - Appium on App Center can't switch between iOS and Android (Java) Appium-应用在测试完成前关闭 - Appium - App closes before test gets completed 如何编写iOS的第一个Appium测试 - How Do I Write My First Appium Test For iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM