Image rotation is not working

Hello,

When i click on image rotation button in my application then its not working. All my test case is run successfully still rotating function is not working. then i change my xpath and used web recording features to find the xpath then in log its showing object is null. . I am posting the log file below

Test Cases/AddListingWithExcel FAILED because (of) (Stack trace: java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null.

at org.openqa.selenium.By.xpath(By.java:113)

at com.kms.katalon.core.webui.common.WebUiCommonHelper.buildLocator(WebUiCommonHelper.java:500)

at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElements(WebUiCommonHelper.java:718)

at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:948)

at com.kms.katalon.core.webui.common.WebUiCommonHelper$findWebElement.call(Unknown Source)

at clickEvent.SelectServices.clickUsingJS1(SelectServices.groovy:94)

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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)

at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:144)

at clickEvent.SelectServices.invokeMethod(SelectServices.groovy)

at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:46)

at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:53)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)

at Script1532079838120.run(Script1532079838120.groovy:104)

at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)

at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)

at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:294)

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:285)

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:264)

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:256)

at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:200)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:99)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:90)

at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)

at TempTestCase1542893445176.run(TempTestCase1542893445176.groovy:22)

at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)

at groovy.lang.GroovyShell.run(GroovyShell.java:518)

at groovy.lang.GroovyShell.run(GroovyShell.java:507)

at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)

at groovy.ui.GroovyMain.run(GroovyMain.java:384)

at groovy.ui.GroovyMain.process(GroovyMain.java:370)

at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)

at groovy.ui.GroovyMain.main(GroovyMain.java:109)

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.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)

at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)

)

clickEvent.SelectServices.clickUsingJS1:94

clickEvent.SelectServices.invokeMethod:0

Test Cases/AddListingWithExcel.run:104

Any help from katalon forum experts will be appreciated.

Thanks,
Nazneen

Screenshot_1.png

Cannot find elements when the XPath expression is null.

You fell into a pit. See the following discussion

1 Like

Thanks Kazurayam for your reply.

This error founds when I run it using web recording but when I select xpath manually and run the code then my test case passes successfully without any error but image is not rotated in browser.
So how can I solve this? can you help me out on this?

Here is my code.

CustomKeywords.‘clickEvent.SelectServices.clickUsingJS1’(findTestObject(‘Add Listing/Page_Workilo Create Listing/Rotate Image f/rotate image’),7)

CustomKeywords.‘clickEvent.SelectServices.clickUsingJS1’(findTestObject(‘Object Repository/Add Listing/Page_Workilo Create Listing/Rotate Image f/Rotate image button left’),5)

CustomKeywords.‘clickEvent.SelectServices.clickUsingJS1’(findTestObject(‘Object Repository/Add Listing/Page_Workilo Create Listing/Rotate Image f/Rotate save button’),5)

If I were you, I would review the code of clickEvent.SelectServices.clickUsingJS1, insert javascript console.log() to see how your javascript code is behaving. First of all, you should check if your javascript function is actually receiving a click event or not.

Hi kazurayam,

You can see the log view. all is working fine.still found errors

Screenshot_2.png

The log certainly shows that Katalon found web elements to click, yes.

But I do not see it any log lines that indicate CustomKeywords.‘clickEvent.SelectServices.clickUsingJS1’ has clicked it. I have a doubt that the clickUsingJS1 method does not click the element. Please check the code.

But using the above code all the previous click operation have been working fine.
Can you please tell me whats the wrong with my below code.

CustomKeywords.‘clickEvent.SelectServices.clickUsingJS1’(findTestObject(‘Add Listing/Page_Workilo Create Listing/Rotate Image f/rotate image’),7)

CustomKeywords.‘clickEvent.SelectServices.clickUsingJS1’(findTestObject(‘Object Repository/Add Listing/Page_Workilo Create Listing/Rotate Image f/Rotate image button left’),5)

CustomKeywords.‘clickEvent.SelectServices.clickUsingJS1’(findTestObject(‘Object Repository/Add Listing/Page_Workilo Create Listing/Rotate Image f/Rotate save button’),5)

Thanks,

You have a Test Object named ‘Add Listing/Page_Workilo Create Listing/Rotate Image f/rotate image’. Please share the selector of it (xpath?)

And also please share the HTML fragment of the part which the Test Object is targeting.

I suppose the selector is selecting a HTML element, but the element has no click-event handler in JavaScript registered.

Hi,
I have attached the HTML in zipper file and xpath for the respective codes are :

for rotate image xpath:
//a[@id=‘popup3’]

Rotate button to left
//i[contains(@class,‘button_left’)]

After rotating save button
//button[contains(@class,‘save_rotate’)]

Thanks,
Nazneen

New folder (2).zip

I have made a demo project at

----

Description

I made a Katalon Studio project using the HTML which nazneen provided. It opens the locally saved HTML and do try clicking buttons to rotate the image.

I used Web Recorder tool to generate a few Test Objects.

Web Recorder generated a Test Case

I modified this test case slightly to fix a problem: inserted a line:

WebUI.scrollToElement(findTestObject('Object Repository/Page_Workilo  Create Listing/a_Rotate Image'), 10)

When I ran the test case TC1, it succeeded without error. And I could see the image was rotated by WebUI.click().

Of course, I did not changed the target HTML at all.

What I observed.

In the log of reproduction, I found a message as follows:

Clicking on object: 'Object Repository/Page_Workilo_ Create Listing/i_Xfa fa-roate-left button_'

This message clearly indicated that Katalon Studio DID click the rotate-left button.

nazneen, the originator of the discussion, posted a screenshot of his log. In his log, I found that the message “Clicking on object …” is missing in his case. This would indicate that Katalon Studio on nazneen’s machine DID NOT click the rotate-left button. Why not? — I do not have any clue.

Conclusion

I could not reproduce the nazneen’s problem using the ZIP file provided by him.

“Clicking on object …” message clearly indicates there is something different between nazneen and me. However I don’t see what.

The HTML has the following fragment for the roate-* buttons:

<label class="" id="rotate_right">
    <i class="fa fa-rotate-left  button_right" aria-hidden="true" data="upload1" style=""></i>
</label> 
<label class="" id="rotate_left">
    <i class="fa fa-rotate-right  button_left" aria-hidden="true" data="upload1" style=""></i>
</label> 

The xpath I used was this:

//label[@id='rotate_left']/i

The xpath nazneen used was this:

//i[contains(@class,'button_left')]

The xpaths are different. But it does not seem to explain the difference of test behavior.

Thanks kazurayam for your solution. Even when I run the rotate button test cases separately its working fine. but its not work in combine test cases. So I have make a separate test case and run it and its working perfectly. :slight_smile:

another problem I am facing in image upload.The image upload allows maximum 10 image uploads and after 10 an alert msg will generate. But in my case after 9 images upload an alert message generates hence 10th images is not uploaded. can you help me on this?

can you help me on this?

Can you provide free access to your web app under test? Otherwise, I do not think I can help you.