Silk Mobile

Table of Contents (Homepage)

Ruby

Here are instructions on how to export Silk Mobile scripts to Ruby code:

Get script code in Ruby:

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 Ruby.

images/download/attachments/3310237/Ruby1.png

Code will automatically generate in Ruby language.

images/download/attachments/3310237/Ruby3.png

Step 4: Copy the generated code in Ruby and paste it into a text file. Here is an example of such a generated code:

load "Client.rb"
# Create client using defaults or using hostname and port number
client = Mobile::Client.new('127.0.0.1', 8890, true)
client.setProjectBaseDirectory("C:\\Users\\User\\workspace\\project1")
client.setReporter2("html", "reports", "Untitled")
client.setDevice("adb:Nexus 9")
client.launch("com.experitest.ExperiBank/.LoginActivity", true, false)
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(false);
# Releases the client so that other clients can approach the agent in the near future.
client.releaseClient();


Step 5: Save it with .rb extension.


Run your script:

Step 1: Copy the file Client.rb from the <SilkMobile>\clients\ruby folder and paste it to the same directory where your Ruby script is saved.

images/download/attachments/3310237/Ruby5.png

Step 2: From the command line go to the script location and run it using the command: ruby <ScriptName>

images/download/attachments/3310237/Ruby6.png