Silk Mobile

Table of Contents (Homepage)

Perl

To export a code to Perl, you need to do the following things:

  1. Code in Perl language

  2. Integrate Silk Mobile and Perl.

Get script code in Perl:

Step 1: Create a test case.

Step 2: Click on the Code tab.

images/download/attachments/3310271/Perl1.png

Step 3: Click on the drop down button of Languages and Select Perl.

images/download/attachments/3310271/Perl2.png

Code will automatically generate in Perl language.

images/download/attachments/3310271/Perl3.png

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 -w
use strict;
use Data::Dumper;
require ExperitestClient;
# Create client using defaults or using hostname and port number
my $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:

  1. Need to integrate the perl environment with Silk Mobile built-in clients located in the installation folder under the ../clients/perl subfolder

  2. Copy the file Experitest.pm and paste it on the same directory where your Perl script is saved.

  3. Need to install RPC::XML module:

    1. Open ppm.bat (Perl Package Manager)

    2. Search for "rpc xml data"

      images/download/attachments/3310271/image82.gif
  4. Select this package

    1. Click on 'Run marked Actions'.

    2. Wait for installation.

images/download/attachments/3310271/image83.gif

Run your script:

  1. From the command line go to the script location and run it using the command: perl <ScriptName>

images/download/attachments/3310271/Perl4.png

Another way to run the Perl Script is on the PerlIDE "Padre".

  1. You can download the PerlIDE from the Link given below:-
    DWIM Perl 5.14.2.1 (v7).

  2. Install this IDE and add rpc::xml module.You should download the module librpc-xml-perl_0.77.orig.tar.gz file.

  3. You can add this module by clicking on Tools -> Module Tools -> Install Local Distribution.

images/download/attachments/3310271/Perl5.png

In the following screenshot you will see that rpc::xml module is installing.

images/download/attachments/3310271/Perl6.png

Run the Script:-

  1. Copy the code from Silk Mobile and paste in the framework.

    images/download/attachments/3310271/Perl7.png
  2. Save the ExperitestClient.pm file on the same directory with your Script.

  3. Click on 'Run Script' and execute the script.

    images/download/attachments/3310271/Perl8.png