1

LeanFT & Java: Run tests in Docker containers My Java-Based LeanFT Tests are working fine on my local Machine with IntelliJ, JUnit and LeanFT:

Chrome opens, I see the test runs and everything is ok.

Now I want to run these tests on in a Docker Container.

When my Test only does a simple naviagtion, everthing is ok:

@test
public void simpleTest2() throws GeneralLeanFtException {

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

}

Docker starts, get LeanFt License and runs the Test:

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

The problem:

When I add a WebElement into my test, it doesn't work (and in IntelliJ it works with LeanFT-Runner)

Something like this:

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

Error is:

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)

Has anybody an idea or a running example?

1 Answers1

0

Is the element really there?

To debug the answer to that try to just browser.getPage().getText() and use the Reporter api to report the value, or println it or whatever. Do this after a browser.navigate and if it works, it should work for any other LeanFT command.

You could even describe the body of the html and log the innerHTML value, like so:

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

Is the browser extension enabled?

A launch will work with or without the browser extension enabled but, for complex execution, you'll need to enable the LeanFT browser agent.

Is it the correct description?

As I can see, the initial description needs:

  • no accesibilityName,
  • no id,
  • "menu" role,
  • a <ul> element
  • and index must be 1.

What if the index is 2? Are you 100% sure the index will be the same on all browsers/all machines? What if it's not a Menu element? Does the description above work if you use a WebElement instead?

Try to eliminate the risk of having a wrong value, and limit the description to stuff that you know 100% sure won't change from browser to browser.

Using Object Identification Center can help a lot in this direction.

Did you answer with yes to all questions above?

Well, LeanFT works in that case, but it doesn't work as expected. It might be a LeanFT bug in this case.

Adelin
  • 7,809
  • 5
  • 37
  • 65