Tests fail due to low resolution using Lab Service (SSE) with auto-login feature

Automated tests failing, usually due to object not found in application under test

The ALM Lab Service, using the auto-login functionality, will establish a remote session on the host machine.

The native resolution of the session is determined by the video drivers used on the physical machine or virtual machine.

In some cases this causes a lower than normal screen resolution such as 800×600 which causes UFT to not locate the objects on the screen of the application under test.

To fix this upgrade and/or configure new video drivers on the physical box or VM which support the screen resolution established when the automated test was recorded using UFT.

Make sure the native resolution provided by the video drivers supports the same resolution when the test was recorded.

To set the resolution use: https://social.msdn.microsoft.com/Forums/azure/en-US/1c215514-aeef-41d9-b47b-5c838a0bf83f/how-to-change-the-vm-default-screen-resolution?forum=WAVirtualMachinesforWindows

Advertisements

How to upload Selenium tests to StormRunner Functional

SRF enables you to upload Web Selenium tests as SRF assets.

Upload your Selenium test

Before uploading a Selenium test to SRF, ensure that you first define the SRF server, port, client ID, and client secret in your test.

Then, do any of the following, as needed:

Applitools If you want to add Applitools visual testing steps to your test, see Add Applitools code to your Selenium script post.
Ruby If you are uploading a Ruby script to SRF, continue with Prepare a Ruby .zip for upload post.
Packaging multiple scripts To package multiple scripts together, continue with Prepare a Selenium .jar file for upload post.
JUnit tests If your script includes multiple tests in a single JUnit class, SRF runs all tests of the defined class.

If you do not want all of these tests to be run in SRF, comment out the relevant lines as needed before uploading.

When you’re done preparing your test, upload Selenium tests to SRF from the SRF SCRIPTS tab.

Prepare a Selenium .jar file for upload

Package your Selenium scripts as a .jar archive to upload to SRF.

Do the following:

1. Make sure you have the following prerequisites before you start:

Test script Ensure that your script can run remotely in SRF.

Note: We recommend making a copy of your original script in the same location for reference.

Maven Make sure you have Maven installed, and that your project is a maven project.
Descriptor file Add a descriptor.json file in your project’s resources folder.

In this file, define the runnableClass value as the path to the class you want to run, including the fully-qualified class name.

2. descriptor.json file with runnableClass example

2. In your Selenium script, replace your Client ID and Secret values with the following static code. You can comment out the CLIENT_ID property.

capabilities.setCapability("SRF_CLIENT_ID", System.getenv("SRF_CLIENT_ID"));
capabilities.setCapability("SRF_CLIENT_SECRET", System.getenv("SRF_CLIENT_SECRET"));

3. Add the RemoteWebDriver location as follows:

RemoteWebDriver driver = new RemoteWebDriver(new URL(System.getenv("SELENIUM_ADDRESS")), capabilities);

4. Compile your code, including any dependencies, and make sure the hierarchy remains stable.

Example: Compiling a .jar file with dependencies

5. From your IDE or the command line, run a maven clean install command.

Your compiled .jar file will be available for upload in your /target folder.

Continue with Basic upload steps to upload your .jar file to SRF.

Prepare a Ruby .zip for upload

To upload your Ruby test to SRF, you must first package the test as a .zip file.

Do the following:

· Include a Rakefile in your zip, including a default task that describes your test. SRF runs the default task when running your uploaded test.

The Rakefile filename is case-sensitive.

· Optionally, define parameters in your script to test different features in each test run.

For example, if you have a parameter named FEATURE_PATH, add the following code to your test:

t.cucumber_opts = '--format pretty ".\' + ENV["FEATURE_PATH"] + '"'

Then, continue with Basic upload steps to upload your .zip file to SRF.

Note: SRF supports specific frameworks out of the box. If your test requires additional components, they must be included in the zip file you upload.

For example, use the –install-dir flag of a gem command to install the component locally.

Selenium code samples for upload

Use the following code as samples when preparing Selenium tests for upload.

Selenium Java code sample

package com.microfocus.srf;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;

/** 
 * Micro Focus StormRunner Functional Selenium Java upload example
 */
public class SeleniumUpload
 {private static RemoteWebDriver driver;
 @BeforeClasspublic static void configToSRF()throws MalformedURLException{
 DesiredCapabilities capabilities = DesiredCapabilities.chrome();
 capabilities.setCapability("SRF_CLIENT_SECRET", System.getenv("SRF_CLIENT_SECRET"));
 capabilities.setCapability("name","My Uploaded Selenium Example");

 URL SRF_URL = new URL( System.getenv("SELENIUM_ADDRESS"));
 driver = new RemoteWebDriver(SRF_URL, capabilities);
 }

 @Testpublic void test() {
 driver.get("http://www.google.com");// Find the text input element by its name
 WebElement element = driver.findElement(By.name("q"));// Enter something to search for
 element.sendKeys("StormRunner Functional");// Now submit the form. WebDriver will find the form for us from the element
 element.submit();

 }

 @AfterClass
 public static void closeBrowser({
 driver.quit();
 }
}

Selenium JavaScript code sample

This example opens the Advantage Online Shopping site and performs a search. It then checks a price and adds an item to the cart, checks out and pays for the item. During payment phase, the example checks the total cost against the verified price.

This example also verifies specific parameter values as defined in SRF, or uses a defined set of default values.

var webdriver = require('selenium-webdriver'),
 By = webdriver.By,
 until = webdriver.until;
var assert = require('selenium-webdriver/testing/assert');

//This example specifies values for input parameters in SRF
//Parameter names should be as shown below

var categoryToFind = process.env.categoryToFind;
var itemToFind = process.env.itemToFind;
var expectedPrice = process.env.expectedPrice;
var driver;

//In case input parameters were not specified in SRF, default values will be used:
 if (categoryToFind==undefined)
 categoryToFind="speakers";
 if (itemToFind==undefined)
 itemToFind="Bose Soundlink Bluetooth Speaker III";

 if (expectedPrice==undefined)
 expectedPrice="$269.99";
describe('DEMO Online Shopping Selenium', function () {
 before(function(done){
 var capabilities = {
 browserName: 'chrome',
 SRF_CLIENT_ID: process.env.SRF_CLIENT_ID,
 SRF_CLIENT_SECRET: process.env.SRF_CLIENT_SECRET
 };
 driver = new webdriver
 .Builder()
 .withCapabilities(capabilities)
 .usingServer(process.env.SELENIUM_ADDRESS)
 .build();
 driver.get('http://advantageonlineshopping.com/#').then(function() {
 console.log("open Online Shopping web page");
 done();
 });
});

it('should search required category', function (done) {
 driver
 .wait(until.elementLocated(By.xpath("//DIV[@id="mobileSearch"]/INPUT[1]"), 5000))
 .then(function(searchFieldElement){
 searchFieldElement.sendKeys(categoryToFind);
 })
 .then(()=>driver.findElement(By.css("#mobileSearch > #Layer_1")).click())
 .then(done);
 });

it('should click on ' + itemToFind + ' in list of founded items', function (done) {
 var element = driver.findElement({partialLinkText:itemToFind, tagName:'LI'});
 driver
 .actions()
 .click(element)
 .perform();
 done();
});

it('should add item into the cart',function(done){
 driver
 .wait(until.elementLocated(By.xpath("//DIV[@id="productProperties"]/DIV/BUTTON[normalize-space()="ADD TO CART"]"), 5000))
 .then(function(){
 driver
 .findElement(By.xpath("//DIV[@id="productProperties"]/DIV/BUTTON[normalize-space()="ADD TO CART"]"))
 .click()
 .then(done);
 });
});

it('should click on cart icon',function(done){
 driver
 .findElement(By.xpath("//HEADER[1]/NAV[1]/UL[1]/LI[1]/A[1]"))
 .click()
 .then(done);
});

it('should check item price',function(done){
 var itemPrice = driver.findElement(By.css("div#shoppingCart > table > tfoot > tr:nth-child(1) > td:nth-child(2) > span:nth-child(2)"));
 itemPrice
 .getText()
 .then(function(elementText){
 assert(elementText).equals(expectedPrice);
 })
 .then(done);
 });

it('should click on checkout button',function(done){
 driver
 .findElement(By.xpath("//DIV[@id="shoppingCart"]/TABLE[1]/TFOOT[1]/TR[2]/TD[1]/BUTTON[1]"))
 .click()
 .then(done);
 });

it('should fill existing user details',function(done){
 driver
 .findElement(By.xpath("//DIV[@id="orderPayment"]/DIV[1]/DIV[1]/DIV[1]/SEC-FORM[1]/SEC-VIEW[1]/DIV[1]/LABEL[1]"))
 .click()
 .then(
 driver
 .findElement(By.xpath("//DIV[@id="orderPayment"]/DIV[1]/DIV[1]/DIV[1]/SEC-FORM[1]/SEC-VIEW[1]/DIV[1]/INPUT[1]"))
 .sendKeys('SRF_DEMO')
 .then(
 driver
 .findElement(By.xpath("//DIV[@id="orderPayment"]/DIV[1]/DIV[1]/DIV[1]/SEC-FORM[1]/SEC-VIEW[2]/DIV[1]/LABEL[1]"))
 .click()
 .then(
 driver
 .findElement(By.xpath("//DIV[@id="orderPayment"]/DIV[1]/DIV[1]/DIV[1]/SEC-FORM[1]/SEC-VIEW[2]/DIV[1]/INPUT[1]"))
 .sendKeys('SRFdemo1234')
 .then(done)
 )));
});

it('should click login button',function(done){
 driver
 .findElement(By.xpath("//DIV[@id="orderPayment"]/DIV[1]/DIV[1]/DIV[1]/SEC-FORM[1]/SEC-SENDER[1]/A[1]"))
 .click()
 .then(done);
 });

it('should check total price',function(done){
 var totalPrice = driver.findElement(By.css("div#userCart > div:nth-child(5) > label:nth-child(2) > span"));
 totalPrice
 .getText()
 .then(function(elementText){
 assert(elementText).equals(expectedPrice);
})
 .then(done);
});

it('should click next button',function(done){
 driver
 .findElement(By.xpath("//DIV[@id="userSection"]/DIV/DIV/BUTTON[normalize-space()="NEXT"]"))
 .click()
 .then(done);
 });

it('should specify user details for buying items',function(done){

 driver
 .findElement(By.xpath("//DIV/SEC-FORM/SEC-VIEW/DIV/LABEL[normalize-space()="SafePay username"]"))
 .click()
 .then(
 driver
 .findElement(By.css("div#paymentMethod > div > div:nth-child(3) > sec-form > sec-view:nth-child(1) > div > input"))
 .sendKeys('testTest')
 .then(
 driver
 .findElement(By.xpath("//DIV/SEC-FORM/SEC-VIEW/DIV/LABEL[normalize-space()="SafePay password"]"))
 .click()
 .then(
 driver
 .findElement(By.css("div#paymentMethod > div > div:nth-child(3) > sec-form > sec-view:nth-child(2) > div > input"))
 .sendKeys('testTEST1234')
 .then(done)
 )));
});

it('should uncheck checkbox "save cahnges to profile"',function(done){
 driver
 .findElement(By.xpath("//DIV[2]/SEC-FORM[1]/DIV[1]/INPUT[1]"))
 .isSelected()
 .then(function(elementSelectedState){
 if (elementSelectedState)
 driver
 .findElement(By.xpath("//DIV[2]/SEC-FORM[1]/DIV[1]/INPUT[1]"))
 .click()
 .then(done);
 });
 });

it('should click on "Pay now" button',function(done){
 driver
 .findElement(By.xpath("//DIV[2]/SEC-FORM[1]/DIV[2]/LABEL[1]/SEC-SENDER[1]/A[1]"))
 .click()
 .then(done);
 });

 it('should check price in order details',function(done){

 var totalPrice = driver.findElement(By.css("div#orderPaymentSuccess > div > div:nth-child(3) > div:nth-child(4) > label > a"));
 totalPrice
 .getText()
 .then(function(elementText){
 assert(elementText).equals(expectedPrice);
 })
 .then(done);
 });

 after(function(done){
 driver.quit().then(done);
 });
});

Sample Ruby .zip file

The following is an example of the contents of a zip file containing a Ruby test ready for upload:

The files in this example include the following code:

your.feature file

In this example, the your.feature file includes a cucumber test:

Feature: Bing can search
Background:
 Given I am on http://bing.com
Scenario: Search for a term
 Then I will search for "SRF"
 And click the MagnifyGlass
 Then I should see "SRF"

steps.rb file

In this example, the steps.rb file contains the step definitions for the cucumber test:

require "capybara/cucumber"
Given /^I am on (.+)$/ do |url|
 visit (url)
end
Then /^I will search for "(.*?)"$/ do |searchText|
 fill_in 'q', :with => searchText
end
And /^click the MagnifyGlass$/ do
 find(:css,'input[type=submit]').click
end
Then /^I should see "(.*?)"$/ do |searchText|
 expect(page).to have_content(searchText)
end

Rakefile file

In this example, the Rakefile contains a default task, which is executed by SRF when running your test.

require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:default) do |t|
 t.cucumber_opts = '--format pretty ".\features\your.feature"'
end

How to Upload UFT tests to StormRunner Functional

Upload a Web or Mobile test from UFT to SRF to use it in modular automation tests in the cloud.

Upload tests from UFT

If you already have the test opened in UFT, or the test is conveniently accessible from UFT, use the SRFbutton in the UFT toolbar to upload your test.

1. Verify that you have a valid connection to the SRF lab.

Connect to SRF

2. In the UFT toolbar, click the Upload to StormRunner Functional button arrow.

Select one of the following:

Upload From File System Drag and drop the test in the upload box, or browse to the test you want to upload.
Upload Active Test Select to upload the test that’s currently active in UFT.

3. Optionally, enter a new name for your test in SRF.

4. Select your test type:

o Select Mobile only if you are testing mobile apps on mobile devices.

o Select Web if you are testing browsers, whether they are mobile or desktop browsers.

Note: Cross browser testing defined by browser parameters in UFT is ignored by SRF.

Define your testing environment in SRF before running your test.

5. Click Upload. Your test is zipped, together with any relevant external resources, and uploaded to SRF.

When the upload is complete, UFT displays a link to the test in SRF. Your test remains open in UFT.

Data tables in uploaded tests

Content in data tables in uploaded UFT tests ignored, although the rows are kept, and use values defined in SRF.

For example, if your data table includes rows for Chrome and Android, the values in the data table are ignored, but the test is run in two iterations for the environments defined in SRF.

Upload tests from SRF

Upload UFT tests from within SRF from the SCRIPTS page.

How to upload LeanFT tests in StormRunner Functional

StormRunner Functional enables you to upload Web and Mobile tests from LeanFT as SRF assets.

Edit your LeanFT test before uploading

You may need to edit your test before uploading it to SRF. Only .js scripts are editable in SRF. All other file types are read-only.

Before uploading a LeanFT test to SRF, modify your code as needed in the following scenarios:

Add visual testing steps

Integrate your LeanFT test with both SRF and Applitools.

To do this, add code as needed to define your Applitools visual testing steps and environment variables.

JavaScript: Nest multiple describe code

If your JavaScript test has multiple describes, nest these using a single set of initialization and cleanup lines.

Remove any LFT.init() and LFT.cleanup() operations from the nested describe code. These lines should appear only once per test.

Ensure that these operations are included in the top-level describe code. If they’re missing:

· Add LFT.init() to the before() function

· Add LFT.cleanup() to the after() function

Note: For Java and C# tests, use LeanFT templates to ensure this code is organized correctly.

Multiple tests in JUnit classes

If your script includes multiple tests in a single JUnit class, SRF runs all tests of the defined class.

If you do not want all of these tests to be run in SRF, comment out the relevant lines as needed before uploading.

Preparing JAR files for upload

When preparing your JAR file for upload, ensure that you do not include JUnit and LeanFT Java SDK dependencies.

For example, in IntelliJ, do the following:

1. Create your JAR as empty, with no dependencies.

2. Then, add the project’s compile output to the JAR file, as well as any other dependencies required for your test run.

Note: Do not add the LeanFT, JUnit, and Hamcrest dependencies.

LeanFT 14.03 Java

If you are working in Java with LeanFT version 14.03 or lower, ensure the following:

· That the following line is uncommented in the leanft.properties file

· The autoLaunch value is false, as defined by default.

autoLaunch=false

When you’re done preparing your test, upload LeanFT tests to SRF from the SRF SCRIPTS tab.

Run results for uploaded LeanFT tests

Snapshots in run results for uploaded LeanFT tests are affected by snapshot levels set in the script.

LeanFT code samples for upload

Use the following code samples when creating LeanFT tests to upload to SRF.

LeanFT Java code sample for upload (Web)

The following code sample browses to the Advantage Online Shopping site, waits for the page to load, and then closes the browser.

Note: The Chrome browser defined in this sample will be overridden by any browser selected in SRF for a specific test run.

package com.company;

import com.hp.lft.sdk.web.Browser;
import com.hp.lft.sdk.web.BrowserDescription;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.hp.lft.sdk.*;
import com.hp.lft.sdk.web.*;
import com.hp.lft.verifications.*;
import unittesting.*;
import static org.junit.Assert.assertTrue;

public class LeanFtTest extends UnitTestClassBase
 {public LeanFtTest()
 {//Change this constructor to private if you supply your own public constructor
 }

 @BeforeClass
 public static void setUpBeforeClass() throws Exception
{
 instance = new LeanFtTest();
 globalSetup(LeanFtTest.class);
 }
 @AfterClass
 public static void tearDownAfterClass() throws Exception {
 globalTearDown();
}
 @Before
 public void setUp() throws Exception {
 }
 @After
 public void tearDown() throws Exception{
 }
 @Test
 public void test() throws GeneralLeanFtException {
 BrowserDescription bd = new BrowserDescription();
 bd.set("type", "Chrome");
 Browser browser = SrfLab.launchBrowser(bd);
 browser.navigate("http://www.advantageonlineshopping.com");
 browser.sync();

 browser.close();
}

LeanFT JavaScript code sample for upload (Web)

This example opens the Advantage Online Shopping site and performs a search. It then checks a price and adds an item to the cart, checks out and pays for the item. During payment phase, the example checks the total cost against the verified price.

This example also verifies specific parameter values as defined in SRF, or uses a defined set of default values.

var LFT = require('leanft');
var SDK = LFT.SDK;
var Web = LFT.Web;
var whenDone = LFT.whenDone;
var expect = require('leanft/expect');
describe('SRF uploaded LeanFT test example with input parameters',function(){
 var browser
 before(function(done){
 SDK.init({});

 whenDone(done);
 });
 beforeEach(function(done){
 LFT.beforeTest();
 Web.Browser.launch('chrome').then(function(b){
 browser = b;
 });
 whenDone(done);
 });
 it('should validate the price of the chosen item',function(done){
 //Example for specifying values for input parameters from SRF UI
 //Parameter names should be same as below (with default values in case they are not set)
 var categoryToFind = process.env.categoryToFind || "speakers";
 var itemToFind = process.env.itemToFind || "Bose Soundlink Bluetooth Speaker III";
 var expectedPrice = process.env.expectedPrice || "$269.99";

 browser.navigate("http://advantageonlineshopping.com/");
 var searchEdit = browser.$(Web.Edit({type:"text", placeholder:"Search", tagName:"INPUT", name:"WebEdit"}));
 searchEdit.setValue(categoryToFind);
 var layer1 = browser.$(Web.Element({accessibilityName: '', innerText: '', tagName: 'svg', index: 10}));
 layer1.click();

 var itemInList = browser.$(Web.Element({tagName:"A", innerText:itemToFind}));
 itemInList.click();

 var itemPrice = browser.$(Web.Element({xpath:"//DIV[@id="Description"]/H2[1]",className:"roboto-thin screen768 ng-binding",tagName:"H2"}));

 //Example of checkpoints(expects) validation:
 expect(itemPrice.outerText()).toEqual(expectedPrice);
 whenDone(done);
 });

 afterEach(function(done){
 LFT.afterTest();
 if(browser){
 browser.close();
 }
 whenDone(done);
 });
 after(function(done){
 SDK.cleanup();
 whenDone(done);
 });
});

LeanFT JavaScript code sample for upload (Mobile)

This example opens the Advantage Online Shopping app on the Mobile Center device named srf-device. The script then logs in and logs out again.

var LFT = require("leanft");
var SDK = LFT.SDK;
var Mobile = LFT.Mobile;
var whenDone = LFT.whenDone;
var LFTexpect = require("leanft/expect");
var SwipeDirection = Mobile.SwipeDirection;
var argv = require('yargs').argv;
 describe("Advantage App upload script Demo",function(){
 var app;
 this.timeout(2400000);
 beforeEach(function(done){
 SDK.init();
 LFT.SrfLab.lockDevice({
 name:'srf-device'
 }).then(function(d){
 device = d;
 app = device.$(Mobile.Application({
 identifier:"com.hpswdemo.advantageinc",
 name:"Advantage",
 version:"38",
 isPackaged :true
 }
 ));
 app.install();
 app.restart();
 }
 );

 whenDone(done);
 });
 it("Advantage",function(done){
 var userName = app.$(Mobile.Edit({
 hint:"User name",
 className:"Input",
 resourceId:"loginUserNameEditText",
 mobileCenterIndex:0
 }
 ));
 var password = app.$(Mobile.Edit({
 hint:"Password",
 className:"Input",
 resourceId:"loginPasswordEditText",
 mobileCenterIndex:1
 }
 ));
 var login = app.$(Mobile.Button({
 text:"LOGIN",
 className:"Button",
 resourceId:"loginButton",
 mobileCenterIndex:0
 }
 ));

 var menu = app.$(Mobile.UiObject({
 className:"ImageView",
 resourceId:"up",
 mobileCenterIndex:12
 }
 ));

 var account = app.$(Mobile.Label({
 text:"ACCOUNTS",
 className:"Label",
 container:"Table[0][0][0]",
 resourceId:"menuItemTextView",
 mobileCenterIndex:0
 }
 ));

 var savings = app.$(Mobile.Label({
 text:"Savings",
 className:"Label",
 container:"Table[1][0][0]",
 resourceId:"accountNameTextView",
 mobileCenterIndex:3
 }
 ));

 var logOut = app.$(Mobile.Label({
 text:"LOGOUT",
 className:"Label",
 container:"Table[0][7][0]",
 resourceId:"menuItemTextView",
 mobileCenterIndex:0
 }
 ));

 var yesLogOut = app.$(Mobile.Button({
 text:"Yes",
 className:"Button",
 resourceId:"button1",
 mobileCenterIndex:0
 }
 ));
 userName.setText("SRFTest");
 LFTexpect(userName.text()).toBe("SRFTest");
 password.setText("SRF123456");

 login.tap();

 menu.tap();

 account.tap();

 menu.tap();

 logOut.tap();

 yesLogOut.tap();
 whenDone(done);
 });
 afterEach(function(done){
 LFT.SDK.cleanup();
 whenDone(done);
 });
});

JavaScript test with multiple describes

var LFT = require('leanft');
var SDK = LFT.SDK;
var Web = LFT.Web;
var SAPUI5 = LFT.SAPUI5;
var whenDone = LFT.whenDone;
var verify = require('leanft/verify');
describe('Upper describe',function(){
before(function(done){
 LFT.init({});
 whenDone(done);
});
describe('1st Inner describe ',function(){
 var browser;
 before(function(done){
 whenDone(done);
 });
 beforeEach(function(done){
 LFT.beforeTest();
 LFT.SrfLab.launchBrowser({
 type: "Chrome",
 version: "60",
 platform: "Ubuntu 16.04"
 }).then(function(b) {
 browser = b;
 });
 whenDone(done);
 });
 it('tablet link should work',function(done){
 browser.navigate("http://www.advantageonlineshopping.com/#/ ");
 var tablets = browser.$(Web.Link({
 tagName: "DIV",
 innerText: "TABLETS Shop Now "
 }));
 tablets.click();
 var tablet2 = browser.$(Web.Image({
 alt: "",
 type: "normal",
 tagName: "IMG",
 index: 2
 }
 ));
 tablet2.click();
 whenDone(done);
 });

 afterEach(function(done){
 LFT.afterTest();
 whenDone(done);
 });
 after(function(done){
 whenDone(done);
 });
});

describe('2nd Inner describe',function(){
 var browser;
 before(function(done){
 whenDone(done);
 });
 beforeEach(function(done){
 LFT.beforeTest();
 LFT.SrfLab.launchBrowser({
 type: "Chrome",
 version: "60",
 osType: "Windows",
 osVersion: "10"
 }).then(function(b) {
 browser = b;
 });
 whenDone(done);
 });
 it('mice link should work',function(done){
 browser.navigate("http://www.advantageonlineshopping.com/#/ ");
 var mice = browser.$(Web.Link({
 tagName: "DIV",
 innerText: "MICE Shop Now "
 }));
 mice.click();
 var mice2 = browser.$(Web.Image({
 alt: "",
 type: "normal",
 tagName: "IMG",
 index: 1
 }
 ));
 mice2.click();
 whenDone(done);
 });
 afterEach(function(done){
 LFT.afterTest();
 whenDone(done);
 });
 after(function(done){
 whenDone(done);
 });
});
after(function(done){
 LFT.cleanup();
 whenDone(done);
});
});

ALM server occupies large space with many files named java_pidXXXX.hprof

The HPROF are files created as logs for the java virtual machine, they are created automatically by the server in the java virtual machine of ALM.
There was a reason for the server to be slow when these files are being created, because they are huge.
These files can simply be removed to reduce the disk occupation.
However, there’s an option to disable the heap dump file generation, but it is not suggested to do that.
For information how to disable the hprof files please type the sign # before wrapper.java.additional.10=-XX:+HeapDumpOnOutOfMemoryError in the wrapper.conf file.
The wrapper.conf file is located at ~\HP\ALM\wrapper

On the link below could be found more information about these files: http://docwiki.cisco.com/wiki/Java_HProf_Files

What is _system_user_ in ALM and how ALM uses this user

In the Site Administration database schema (the default name qcsiteadmin_db) in the SESSIONS_HISTORY table ALM uses “_system_user_” with a type of ALM Internal Server.

The _system_user_ is an internal user used by ALM with a type of “ALM Server Internal” in order to perform internal operations. It was introduced in ALM 11.

Any operations on ALM entities are monitored by the permissions granted to the user performing them and thus an internal user is needed. For example, QPM Calculation engine needs to access to different projects and entities.

Here are some characteristics for this user:
– It does not have a password and it is internal thus preventing login using this user.
– It does not consume a license. This is a user created for internal server jobs proposes.
– This user is created upon installation/upgrade process.
– It enables automatically on project creation, as part of the TDAmin group. This indicates that the user’s permissions are equal to regular admin user.
– The user is hidden from the Site Administrator’s users list and it does not appear as one of the users enabled on the projects. This is done to prevent deleting the user or changing its properties.
– The records on the user are stored inside the qcsiteadmin_db. If the user list is managed using LDAP, the user is not defined in it. Its scope is only inside ALM since it is not representing a normal user.

Run Appium scripts remotely using StormRunner Functional

This article describes how to set up your Appium environment and run tests remotely in the SRF environment lab.

Prepare your Appium environment

To prepare your environment to run an automated Appium test, you must first configure your working environment, such as Visual Studio or Eclipse, to recognize the Appium project.

Prepare your Appium test

Do the following to prepare your Appium test to run remotely in SRF:

1. In the code the starts the session, replace the Appium server URL and port with the SRF URL and port.

Use the following syntax:

driver = new AndroidDriver(new URL("https://ftaas.saas.hpe.com:443" + "/wd/hub"), capabilities);
driver = new IOSDriver(new URL("https://ftaas.saas.hpe.com:443" + "/wd/hub"), capabilities);

2. In the code that starts the session, add your SRF client ID and secret as capability code.

3. capabilities.SetCapability("SRF_CLIENT_ID", "<placeholder>");
capabilities.SetCapability("SRF_CLIENT_SECRET", "<placeholder>");

3. Make your apps available for the test by uploading them to SRF.

4. Modify your code for deprecated elements and methods

Beginning with version 1.6.3, Appium deprecated the following items:

By.name element for findElement. Make sure to modify your code accordingly.
scrollTo and scrollToExactmethods. Instead, use a driver. execute command, for example,
driver.execute('mobile: scroll', {element: el, toVisible: true})

5. Continue with Run your test.

Run your test

Run your test using the relevant steps for your testing tool:

Run your Appium test in Eclipse

To run your Appium test in Eclipse:

1. Open your project in Eclipse. Set the Appium capabilities as needed, including the server and device information.

2. Launch the test. Check the Eclipse console to ensure that your test is running properly.

Run your Appium test with Apache Ant

To run your Appium test with Ant:

1. Download and install Apache Ant, and set the required environment variables.

2. Open a command dialog box and navigate to your Appium workspace path.

3. Run the command ant <test_name>.java to start running your test.

Check the Ant console to ensure that your test is running properly.

Run a single job project in Jenkins

To run your Appium test as a Jenkins job: (Terminology refers to Jenkins 2.00 and higher):

1. Download and install Apache Ant, and set the relevant environment variables.

2. Open the Jenkins dashboard and click New item.

3. Specify an Item name and click Freestyle project.

4. In the General tab, click Advanced.

5. Select Use custom workspace and enter your Appium workspace path.

6. In the Build section, select Invoke ant.

7. Click the Advanced button. Provide a target name and the full path to the build.xml file in the Build Filefield.

8. Click Save.

9. On the project page, click Build Now.

Run a MultiJob project in Jenkins

To run multiple Appium tests as a Jenkins job: (Terminology refers to Jenkins 2.00 and higher):

1. Prepare several single job freestyle jobs.

2. Click New item and specify a MultiJob project.

3. In the Build section, select MultiJob Phase from the Add build step drop down. Enter a phase name.

4. Click Add jobs and select the first job you want to add. Repeat this step for all of the jobs you want to include in this phase.

5. Select an option from the Job execution type drop down: sequentially or in parallel.

If you are executing multiple jobs, but only have one device, the jobs will be executed sequentially—not in parallel.

6. Optionally, select a continuation condition, for example: Always, Successful, or Completed.

7. On the project page, click Build Now.

Tip: The udid, name, and platformVersion capabilities are optional. You can use the platformNamecapability alone, to instruct the Appium test to look for the next available device.

As your test runs, the device is locked and reserved by you in the SRF mobile lab.

The running tests icon in the upper right corner of SRF indicates that your test is running.

Retrieve Appium logs

A log file is generated while your Appium test runs.

To retrieve the log, use the mc-wd:downloadLogs script and specify the encoding.

When the connector receives this command, it retrieves the contents of the Appium log file for the current testing session, as a string. Attach the string to the response body.

The Appium user’s test code uses the string from the response body and processes it accordingly.

For example:

HashMap<String, String> encoding= new HashMap<String, String>();

encoding.put(“encoding”, “UTF-8”);

String logFileContents = (String) wd.executeScript(“mc-wd: downloadLogs”, encoding);