Hi,
Good Day!!!
I’m trying to get text using gettext but getting error (Root cause: Object Object Repository/test/mytext not found)…
Note: The mytext object is in the object Repository/test/mytext
Can anyone help me with this?
Hi,
Good Day!!!
I’m trying to get text using gettext but getting error (Root cause: Object Object Repository/test/mytext not found)…
Note: The mytext object is in the object Repository/test/mytext
Can anyone help me with this?
Hi Mandy,
Would you be able to share your test code? Could you also share a screenshot of what properties the mytext object has from the repository (double clicking it should open it)?
Thanks,
Chris
also share full log text so we can see exact messages
Chris Trevarthen said:
Hi Mandy,
Would you be able to share your test code? Could you also share a screenshot of what properties the mytext object has from the repository (double clicking it should open it)?
Thanks,
Chris
Hi Chris,
Here are the attachments below,
and in between can you help me with the Xpath,
I have googled for Xpath but they haven’t explained me how to use them in Katalon Mobile Testing.
Can you explain me how to define this “mytext” using Xpath.
.Thanks!!!
Hi Mandy,
Thanks for providing all of that info.
It has been my experience that when I receive an error saying that an object can’t be found, it really cannot be found on the screen, sometimes because it’s hidden by another view or I haven’t given it enough time to show up.
From the initial glance, it looks like your test is set up correctly. One thing you might want to try doing is to put a delay after you tap the Login button:
Mobile.delay(5)
Just to make sure that you’re not looking for the text before it shows on the screen. You can also change the last parameter (currently set to 0) on your Mobile function calls to be a number of seconds to wait.
A way to double check that the element actual is showing on the screen is to add some logging to print out the contents of the screen right before you do your getText() call. You should be able to do that by putting the following import statements at the top of your test case:
import com.kms.katalon.core.logging.KeywordLoggerimport com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactoryimport io.appium.java_client.AppiumDriver
Then in the code for your test, add the following right before the getText() call:
AppiumDriver<?> driver = MobileDriverFactory.getDriver()
KeywordLogger log = new KeywordLogger()
log.logInfo(driver.getPageSource())
When the test runs, you should see an entry in the Log Viewer for “Statement - log.logInfo(driver.getPageSource())” that shows the start of the XML for the screen. If you tap on it, you’ll see all of the XML for the screen on the right-hand pane. If you could copy and share that, I can help troubleshoot why the getText() isn’t working. (I recommend putting it into a text editor first to remove any sensitive data, like package names, etc.)
Hope this helps,
Chris
As for how to define the xpath, if you’re not familiar with what an xpath is, then you can find out some more on the MSDN site:
https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx
If you already know about xpaths, then you can create test objects using xpath by editing the object’s properties (using the screen you pasted above). Check the box for “Detect object” in the row for the “xpath” property (unchecking the other boxes). Paste in your object’s xpath in the “Value” column.
NOTE: Katalon Studio and its underlying tools will only support xpath version 1.0, so you might be restricted in some of the built-in xpath functions you can use.
ALSO NOTE: There is a radio button at the top of the object properties screen for “Selection method” and there is a value for “XPath” - I don’t think this works, so I would rely on the “Attributes” selection.
Hope this helps,
Chris
Chris Trevarthen said:
Hi Mandy,
Thanks for providing all of that info.
It has been my experience that when I receive an error saying that an object can’t be found, it really cannot be found on the screen, sometimes because it’s hidden by another view or I haven’t given it enough time to show up.
From the initial glance, it looks like your test is set up correctly. One thing you might want to try doing is to put a delay after you tap the Login button:
Mobile.delay(5)
Just to make sure that you’re not looking for the text before it shows on the screen. You can also change the last parameter (currently set to 0) on your Mobile function calls to be a number of seconds to wait.
A way to double check that the element actual is showing on the screen is to add some logging to print out the contents of the screen right before you do your getText() call. You should be able to do that by putting the following import statements at the top of your test case:
import com.kms.katalon.core.logging.KeywordLoggerimport com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactoryimport io.appium.java_client.AppiumDriver
Then in the code for your test, add the following right before the getText() call:
AppiumDriver<?> driver = MobileDriverFactory.getDriver()
KeywordLogger log = new KeywordLogger()
log.logInfo(driver.getPageSource())
When the test runs, you should see an entry in the Log Viewer for _"Statement - log.logInfo(driver.getPageSource())"_ that shows the start of the XML for the screen. If you tap on it, you'll see all of the XML for the screen on the right-hand pane. If you could copy and share that, I can help troubleshoot why the getText() isn't working. (I recommend putting it into a text editor first to remove any sensitive data, like package names, etc.) [](https://s3.amazonaws.com/katalon-forum/editor/c8/gue4ko27dzdp.png) Hope this helps, Chris
Hi Chris,
I have checked with the same :
Mobile.delay(10) => it didn’t work in my case.
Adding the code before gettext() also not worked for my case and i haven’t got any xml.
I have checked with other apk i got the message printed but i am not able to crack with my apk.
please refer to screen record (Other demo apk vs my tesing apk)
For demo apk :
With my test apk :
I think its little confusing please refer video in below link :
Thanks!!!
Hi Mandy,
That’s weird that it’s not logging the screen contents for you. Could you try changing the log.logInfo part to log.logWarning just in case your log file settings are to ignore “info” statements?
Chris
Chris Trevarthen said:
Hi Mandy,
That’s weird that it’s not logging the screen contents for you. Could you try changing the log.logInfo part to log.logWarning just in case your log file settings are to ignore “info” statements?
Chris
Hi Chris,
I have changed to log.logwarning but still no luck
Hi Chris,
i was trying to get the text form the object using Xpath
i’m not sure if am doing it right way or wrong
Please help me with this
Below are the images of code,object properties and Object Repository tree structure.
Thanks!!!
Hi Mandy,
For detecting the object by xpath, you should uncheck all of the other lines except for “xpath”. Then double-click on the value for xpath (in your screenshot, it’s currently “//hierarchy/android.width.FrameLayout[1]…”. You’ll want to enter a less brittle xpath instead, so something like:
//*[@class = 'android.widget.TextView' and @text = 'Username or password is incorrect.']
Behind the scenes, Katalon Studio will create an xpath based on the properties you have selected with “Detect object”. You only really need to make your own if you need a lot more control over the object detection or if you need to create the xpath programmatically.
- Chris
Hi Chris,
I tried to get text using xpath but it shows Object is null, I’m not getting and not sure i’m doing it completely wrong or missing something.
This is the code i tried
def errormessage = Mobile.getText(findTestObject('/hierarchy/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.widget.TextView[2]'), 0)println(errormessage)def errormessagetext = Mobile.verifyMatch(errormessage, 'Incorrect email or password.', false)println(errormessagetext)
This the thing i got in console.
[35m[HTTP]e[39m e[37m-->e[39m e[37mGETe[39m e[37m/wd/hub/session/cd3356df-f7f3-4cae-a036-e897cdeb19b5/screenshote[39me[35m[HTTP]e[39m e[90m{}e[39m10-16-2018 04:01:15 PM - [FAILED] - Failed to get text from element (Root cause: java.lang.IllegalArgumentException: Object is null)10-16-2018 04:01:15 PM - [END] - End action : Statement - errormessage = com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.getText(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(/hierarchy/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.widget.TextView[2]), 0)10-16-2018 04:01:15 PM - [FAILED] - Test Cases/hogaarV2/hogarV2 FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Failed to get text from element (Root cause: java.lang.IllegalArgumentException: Object is null) at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
Hi Mandy,
Just to give some more background, you can use the xpath to find an object in a few ways:
You can use the Mobile Recorder/Spy Mobile to save/export a new Test Object in the Object Repository:
https://docs.katalon.com/display/KD/Spy+Mobile+Utility
You can then double-click that Test Object to edit the properties. Edit the Attributes to uncheck everything except the xpath:
Alternatively, you can create a new Test Object in the Object Repository, giving it the “xpath” Name, “equals” Condition, and pasting in the Value of the xpath you want:
https://docs.katalon.com/display/KD/Manage+Test+Object
Finally, if you’d like to find an object by xpath in code, you can do the following:
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
TestObject myNewObject = new TestObject("TheObjectName")
myNewObject.addProperty("xpath", ConditionType.EQUALS, "//html/body")
So in your example above, you’d need to do something like:
def errorMsgObject = new TestObject()
errorMsgObject.addProperty("xpath", ConditionType.EQUALS, "/hierarchy/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.widget.TextView[2]")
def errormessage = Mobile.getText(errorMsgObject, 0)println(errormessage)def errormessagetext = Mobile.verifyMatch(errormessage, 'Incorrect email or password.', false)println(errormessagetext)
Or perhaps, to simplify the xpath, you could change the 2nd line to be:
errorMsgObject.addProperty("xpath", ConditionType.EQUALS, "//*[@class='android.widget.TextView'][1]")
I hope this helps,
Chris
Hi Chris,
This worked for me thanks,
Chris Trevarthen said:
Hi Mandy,
Just to give some more background, you can use the xpath to find an object in a few ways:
Using Mobile Recorder/Spy Mobile
You can use the Mobile Recorder/Spy Mobile to save/export a new Test Object in the Object Repository:
https://docs.katalon.com/display/KD/Spy+Mobile+Utility
You can then double-click that Test Object to edit the properties. Edit the Attributes to uncheck everything except the xpath:
Creating New Test Object in Object Repository
Alternatively, you can create a new Test Object in the Object Repository, giving it the “xpath” Name, “equals” Condition, and pasting in the Value of the xpath you want:
https://docs.katalon.com/display/KD/Manage+Test+Object
Creating New Test Object in Code
Finally, if you’d like to find an object by xpath in code, you can do the following:
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
TestObject myNewObject = new TestObject(“TheObjectName”)
myNewObject.addProperty(“xpath”, ConditionType.EQUALS, “//html/body”)
So in your example above, you'd need to do something like:
def errorMsgObject = new TestObject()
errorMsgObject.addProperty(“xpath”, ConditionType.EQUALS, “/hierarchy/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.widget.TextView[2]”)
def errormessage = Mobile.getText(errorMsgObject, 0)println(errormessage)def errormessagetext = Mobile.verifyMatch(errormessage, ‘Incorrect email or password.’, false)println(errormessagetext)Or perhaps, to simplify the xpath, you could change the 2nd line to be:
errorMsgObject.addProperty(“xpath”, ConditionType.EQUALS, “//*[@class=‘android.widget.TextView’][1]”)
I hope this helps, Chris
Hi Chris,
This worked for me thanks,
Good Day!!!
Hi, am getting the same error in Mobile Automation.
Failed to tap on element ‘Object Repository/Application/CallsObjects/PinCode’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Object Object Repository/Application/CallsObjects/PinCode not found) .
Attached object repository screenshot.
Hi. I also encountered errors like you. Have you solved the problem? I look forward to receiving help
Hey chris i am trying to export data from an excel file in android application testing but i am getting this error
12-07-2020 04:07:16 PM Test Cases/Testing
Elapsed time: 1m - 26.947s
Test Cases/Testing FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Object Object Repository/Profile/android.widget.EditText - Dummy not found
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.stepFailed(MobileKeywordMain.groovy:40)
at com.kms.katalon.core.mobile.keyword.builtin.SetTextKeyword$_setText_closure1.doCall(SetTextKeyword.groovy:76)
at com.kms.katalon.core.mobile.keyword.builtin.SetTextKeyword$_setText_closure1.call(SetTextKeyword.groovy)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:21)
at com.kms.katalon.core.mobile.keyword.builtin.SetTextKeyword.setText(SetTextKeyword.groovy:83)
at com.kms.katalon.core.mobile.keyword.builtin.SetTextKeyword.execute(SetTextKeyword.groovy:66)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.setText(MobileBuiltInKeywords.groovy:1182)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$setText$1.call(Unknown Source)
at Testing.run(Testing:40)
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:393)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1607337434428.run(TempTestCase1607337434428.groovy:25)