LeanFT & Java: запускать тесты в контейнерах Docker

LeanFT и Java: запускать тесты в контейнерах Docker Мои тесты LeanFT на основе Java работают нормально на моей локальной машине с IntelliJ, JUnit и LeanFT:

Хром открывается, я вижу тестовые прогоны и все ок.

Теперь я хочу запустить эти тесты в контейнере Docker.

Когда мой тест выполняет только простую навигацию, все в порядке:

@test
public void simpleTest2() throws GeneralLeanFtException {

    browser.navigate("https://www.google.com");

}

Docker запускается, получает лицензию LeanFt и запускает тест:

dev@ubuntu:~$ docker run -p 5900:5900 -v /home/dev/development/tempprojects/LeanFT_1/target:/tests --env LFT_LIC_SERVER=S021000105693b.adr.admin.ch --env LFT_LIC_ID=10594 --env RUN_MODE=junit --env RUN_CMD=ch.admin.bit.LeanFtTest -t -i -w /tests functionaltesting/leanft-chrome 


LeanFT runtime engine started successfully
License: Concurrent UFT Enterprise Concurrent User
Port: 5095
Version: 14.3.546, (c) Copyright 2015 EntIT Software LLC
Installation Folder: /opt/leanft
Executing junit test: ch.admin.bit.LeanFtTest
JUnit version 4.12
.
Time: 5.778

OK (1 test)

LeanFT runtime engine has stopped successfully

Эта проблема:

Когда я добавляю WebElement в свой тест, он не работает (а в IntelliJ он работает с LeanFT-Runner)

Что-то вроде этого:

Menu dEFRITENMenu = browser.describe(Menu.class, new MenuDescription.Builder()
.accessibilityName("")
.id("")
.role("menu")
.tagName("UL")
.index(1).build());
dEFRITENMenu.select("EN");

Ошибка:

1) simpleTest(ch.admin.bit.LeanFtTest)
com.hp.lft.sdk.ReplayObjectNotFoundException: Cannot identify the object "Web Menu".
Verify that this object's properties match an object currently displayed in your application.
at com.hp.lft.sdk.internal.ReplayExceptionFactory$1.create(ReplayExceptionFactory.java:34)
at com.hp.lft.sdk.internal.ReplayExceptionFactory.createOrDefault(ReplayExceptionFactory.java:197)
at com.hp.lft.sdk.internal.ReplayExceptionFactory.createOrDefault(ReplayExceptionFactory.java:21)
at com.hp.lft.sdk.internal.TestObjectExecuterBehaviorBase$ReplayErrorHandler.onError(TestObjectExecuterBehaviorBase.java:65)
at com.hp.lft.sdk.internal.CommunicationClientImpl.handleError(CommunicationClientImpl.java:221)
at com.hp.lft.sdk.internal.CommunicationClientImpl.send(CommunicationClientImpl.java:96)
at com.hp.lft.sdk.internal.TestObjectExecuterBehavior.executeMethod(TestObjectExecuter.java:33)
at com.hp.lft.sdk.internal.TestObjectBase.executeMethod(TestObjectBase.java:119)
at com.hp.lft.sdk.internal.web.WebMenu.access$100(WebMenu.java:14)
at com.hp.lft.sdk.internal.web.WebMenu$2.invoke(WebMenu.java:52)
at com.hp.lft.sdk.internal.TestObjectOperationWrapper.executeWithEvents(TestObjectOperationWrapper.java:81)
at com.hp.lft.sdk.internal.TestObjectOperationWrapper.executeWithEvents(TestObjectOperationWrapper.java:102)
at com.hp.lft.sdk.internal.web.WebMenu.select(WebMenu.java:56)
at ch.admin.bit.LeanFtTest.simpleTest(LeanFtTest.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
at org.junit.runner.JUnitCore.main(JUnitCore.java:36)

У кого-нибудь есть идея или пример?

1 ответ

Элемент действительно там?

Отладить ответ на то попробуйте просто browser.getPage().getText() и использовать Reporter API, чтобы сообщить значение, или println это или что угодно. Сделайте это после browser.navigate и если он работает, он должен работать для любой другой команды LeanFT.

Вы можете даже описать тело HTML и записать innerHTML значение, вот так:

WebElement htmlBody = browser.describe(WebElement.class, new WebElementDescription.Builder().tagName("BODY").build());
htmlBody.getInnerHTML();

Расширение браузера включено?

Запуск будет работать с включенным расширением браузера или без него, но для сложного выполнения вам потребуется включить агент браузера LeanFT.

Это правильное описание?

Как я вижу, первоначальное описание требует:

  • нет accesibilityName,
  • нет id,
  • "menu" роль,
  • <ul> элемент
  • а также index должно быть 1,

Что делать, если индекс 2? Вы на 100% уверены, что индекс будет одинаковым на всех браузерах / на всех машинах? Что делать, если это не Menu элемент? Работает ли приведенное выше описание, если вы используете WebElement вместо?

Постарайтесь исключить риск неправильного значения и ограничьте описание тем, что, как вы знаете, на 100% точно не изменится от браузера к браузеру.

Использование Object Identification Center может очень помочь в этом направлении.

Вы ответили "да" на все вопросы выше?

Хорошо, LeanFT работает в этом случае, но он не работает, как ожидалось. Это может быть ошибка LeanFT в этом случае.

Другие вопросы по тегам