Web testing on emulated Android - problem with a button

Hello,
I’m supposed to automate a test where I:

  1. open a browser
  2. navigate to an url (Distributor Portal)
  3. fill in the field email
  4. fill in the field password
  5. click on the button Connexion

then theoretically, I should log in. I don’t.

Here’s my Katalon test script:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
import org.openqa.selenium.WebElement as WebElement

WebUI.openBrowser(‘’)

WebUI.navigateToUrl(‘Distributor Portal’)

WebUI.click(findTestObject(‘Object Repository/Page_Distributor Interface/button_Tout accepter’))

WebUI.setText(findTestObject(‘Object Repository/Page_Distributor Interface/input_Email_input-username’), ‘my_email’)

WebUI.setEncryptedText(findTestObject(‘Object Repository/Page_Distributor Interface/input_Mot de passe_input-password’),
‘my_password’)

WebUI.delay(5)

WebUI.click(findTestObject(‘Object Repository/Page_Distributor Interface/button_Connexion’))

//WebElement element = WebUiCommonHelper.findWebElement(findTestObject(‘Object Repository/Page_Distributor Interface/button_Connexion’), 30)
//WebUI.executeJavaScript(“arguments[0].click()”, Arrays.asList(element))
WebUI.delay(60)

WebUI.verifyTextPresent(‘Hallo,’, false)

WebUI.verifyTextPresent(‘Ein neuer Tag beginnt!’, false)

WebUI.closeBrowser()

and I get this error message:

=============== ROOT CAUSE =====================
Caused by: com.kms.katalon.core.exception.StepFailedException: Text ‘Hallo,’ is not present on page

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html

09-07-2021 01:34:04 PM Test Cases/TC01_Log-in_to_DI/Distributor/Mobile

Elapsed time: 2m - 9,434s

Test Cases/TC01_Log-in_to_DI/Distributor/Mobile FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify text ‘Hallo,’ is present
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.verifyTextPresent(VerifyTextPresentKeyword.groovy:83)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.execute(VerifyTextPresentKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextPresent(WebUiBuiltInKeywords.groovy:1723)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextPresent$4.call(Unknown Source)
at Mobile.run(Mobile:41)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:430)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1631014434143.run(TempTestCase1631014434143.groovy:25)
Caused by: com.kms.katalon.core.exception.StepFailedException: Text ‘Hallo,’ is not present on page
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.doCall(VerifyTextPresentKeyword.groovy:79)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.call(VerifyTextPresentKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more

As you can see in my code, I have tried clicking with Javascript, but I get the following error message:

=============== ROOT CAUSE =====================

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html

09-07-2021 01:44:20 PM Test Cases/TC01_Log-in_to_DI/Distributor/Mobile

Elapsed time: 1m - 29,905s

Test Cases/TC01_Log-in_to_DI/Distributor/Mobile FAILED.
Reason:
com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Distributor Interface/button_Connexion’ located by ‘//*[@id=“submit-login”]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1368)
at com.kms.katalon.core.webui.common.WebUiCommonHelper$findWebElement.call(Unknown Source)
at Mobile.run(Mobile:37)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:430)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1631015047902.run(TempTestCase1631015047902.groovy:25)

I’ve been stuck on this on days. I am clueless. Thanks in advance.

I forgot : I work on Windows 10. I use an emulated (Android Studio) Pixel 4 API 30 Android v11.0 Chrome 83.

The test appears to be stopping on this line, saying Hallo, is not present. Note there is a comma trailing the word Hallo – is that correct and expected on the page?

Hello, thank you for your reply. I really can’t script clicking the button Connexion.

The real problem seems to be that the TestObject is found, but not the WebElement. Is that possible ?

I have inspected the web page on mobile with Google Chrome (chrome://inspect#devices). I am positive its id is « submit-login », but Katalon does not find the WebElement basing on the TestObject no matter what I try as an xpath in the Object Repository description.

Any ideas ? The URL i’m talking about is: https://di-pprd1.airliquide.com/fr/fr/login/user , and I’m trying to login on an emulated mobile phone (Android Studio Pixel 2).

Thanks in advance.

Regards

Yes, it’s very possible.

A test object contains reference information to help target a web element. If the references are incorrect, then certainly Katalon will find the test object but the core will fail to find the target web element.

Did you try WebUI.enhancedClick() ?

Aaah… I just looked at the page. Your button resides in an IFRAME element. Be sure to tell Katalon it’s in an iframe:

Thank you, I’ll try that tomorrow.

Regards

PS what’s an iframe ? If it’s not too much to ask.

Regards

This:

Hello ! I tried switching to the iframe (WebUI.switchToIframe(findTestObject("Object Repository/Page_Distributor Interface/iframe))) and now Katalon can’t find the iframe:

com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Distributor Interface/iframe’ located by ‘//iframe’ not found

What is very odd is that the two input fields (username and password) are also in the iframe (am I wrong?) and that findWebElement finds them. I honestly don’t understand what’s going on.

Any ideas ? I’m getting clueless, and desperate.

Thanks in advance,

Regards

Make sure you EITHER…

  1. Set the iframe option in your Test Object for each selector that needs it
  – In this case, Katalon will perform the switch to the iframe for you

OR

  2. Use switchToFrame
  – In this case, your selector must NOT reference the iframe itself.

The point is, don’t use both.

No, you’re correct. I don’t know how or why Katalon is finding those without seeing more of your code.

I did notice that your iframe comes from a different server/domain. Using standard WebDriver/selenium commands should be okay but it might be a concern if we try to use something else later (like JavaScript).

Take a step back from your coding/testing problem and prove you can at least find all the elements you need and check they are visible:

https://docs.katalon.com/katalon-studio/docs/webui-wait-for-element-visible.html

Once you do that, then you should be able to populate fields and click buttons.

Thank you. Your replies are very useful. I hope I can make it work with your help !

Regards

Hello,
Eventually I made it wok by using Mobile.hideKeyboard() between typing the password and clicking the button. Hope this helps.
Regards