To export a code to Perl, you need to do the following things:
Code in Perl language
Integrate Silk Mobile and Perl.
Get script code in Perl:
Step 1: Create a test case.
Step 2: Click on the Code tab.
Step 3: Click on the drop down button of Languages and Select Perl.
Code will automatically generate in Perl language.
Step 4: Copy the generated code in Perl and paste into a text file. Here is an example of such a generated code:
#!/usr/bin/perl -wuse strict;use Data::Dumper;require ExperitestClient;# Create client using defaults or using hostname and port numbermy $client = SeeTest->new('localhost', 8890, 1);$client->setProjectBaseDirectory("C:\\Users\\User\\workspace\\project1");$client->setReporter2("html", "reports", "Untitled");$client->setDevice("adb:Nexus 9");$client->launch("com.experitest.ExperiBank/.LoginActivity", 1, 0);$client->elementSendText("NATIVE", "id=usernameTextField", 0, "company");$client->elementSendText("NATIVE", "id=passwordTextField", 0, "company");$client->click("NATIVE", "text=Login", 0, 1);# Generates a report of the test case.# For more information - http://supportline.microfocus.com/Documentation/books/ASQ/SilkMobile/90/help/Report+Of+Executed+Test$client->generateReport2(0);# Releases the client so that other clients can approach the agent in the near future. $client->releaseClient();
Step 5: Save it with .pl extension.
Integrate to Perl:
Need to integrate the perl environment with Silk Mobile built-in clients located in the installation folder under the ../clients/perl subfolder
Copy the file Experitest.pm and paste it on the same directory where your Perl script is saved.
Need to install RPC::XML module:
Open ppm.bat (Perl Package Manager)
Search for "rpc xml data"
Select this package
Click on 'Run marked Actions'.
Wait for installation.
Run your script:
From the command line go to the script location and run it using the command: perl <ScriptName>
Another way to run the Perl Script is on the PerlIDE "Padre".
You can download the PerlIDE from the Link given below:-
DWIM Perl 5.14.2.1 (v7).
Install this IDE and add rpc::xml module.You should download the module librpc-xml-perl_0.77.orig.tar.gz file.
You can add this module by clicking on Tools -> Module Tools -> Install Local Distribution.
In the following screenshot you will see that rpc::xml module is installing.
Run the Script:-
Copy the code from Silk Mobile and paste in the framework.
Save the ExperitestClient.pm file on the same directory with your Script.
Click on 'Run Script' and execute the script.