Forum Discussion
RohitBBorse
14 years agoContributor
Hi,
I am able to switch the base64 string to image using Base64 class and swing builder as below:
However, I wanted the frame to be saved in local repository rather being displayed for the time being.
Secondly, I again need help for generating images if there exists more than 1 image parts in an xml response as below:
I am working on the same. Please to-time help me with groovy script for the above two issues.
Thanks
Rohit Borse
I am able to switch the base64 string to image using Base64 class and swing builder as below:
import groovy.swing.SwingBuilder
import javax.swing.ImageIcon
import groovy.swing.SwingBuilder
import org.apache.commons.codec.binary.Base64
teststep=context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()
Image='$'+"{"+teststep+"#Response#//ns1:Label/ns1:Parts/ns1:Image}"
Label=context.expand(Image)
b64 = new Base64()
swing = new groovy.swing.SwingBuilder()
i1 = swing.label(icon:new ImageIcon(b64.decode(Label.getBytes())))
frame = swing.frame(title:"LABEL IMAGE", defaultCloseOperation:javax.swing.WindowConstants.DISPOSE_ON_CLOSE) {
panel(){
widget(i1)
}
}
frame.pack()
frame.show()
However, I wanted the frame to be saved in local repository rather being displayed for the time being.
Secondly, I again need help for generating images if there exists more than 1 image parts in an xml response as below:
<ns1:Label>
<ns1:Name>Label01</ns1:Parts>
<ns1:Parts>
<ns1:DocumentPartSequenceNumber>1</ns1:DocumentPartSequenceNumber>
<ns1:Image>HOJBAAAElFTkSuQmCC.....</ns1:Image>
</ns1:Parts>
</ns1:Label>
<ns1:Label>
<ns1:Name>Label02</ns1:Parts>
<ns1:Parts>
<ns1:DocumentPartSequenceNumber>1</ns1:DocumentPartSequenceNumber>
<ns1:Image>dfdJBAAAElFTkSuQmCC.....</ns1:Image>
</ns1:Parts>
</ns1:Label>
I am working on the same. Please to-time help me with groovy script for the above two issues.
Thanks
Rohit Borse
Related Content
- 5 years ago
- 7 years ago
- 3 years ago
- 11 years ago