Articles

Title Body
How to add nodes programmatically in Drupal 7

https://anders.unix.se/2011/06/06/updating-nodes-programmatically-in-dru...

is element present

Here is how to do it in webdriver:

if(!driver.findElements(By.xpath("//*[@id='submit']")).isEmpty()){
//THEN CLICK ON THE SUBMIT BUTTON
}else{
//DO SOMETHING ELSE AS SUBMIT BUTTON IS NOT THERE
}

Create a Custom Entity/Node Title in Drupal 7

<?php
$brand = '[node:field_med_brand_name]';
$medical = '[node:field_med_medical_name]';
$both = '[node:field_med_brand_name] ([node:field_med_medical_name])';
if(empty($medical)) {
  return "$brand";
} else {
  return "$both";
}
?>

How to find and remove a value from an array

If you are working with an array and you need to remove an item from the array, here is how to do it:

 

Using Drupal AND Selenium for data driven testing

This may sound a bit strange to many of you ... but, we have engineered a way to create a framework for managing scheduled selenium launches, and providing data into each launch (data driven) using a Content Management System (Drupal).

Finding a available port number in Windows

See the following page for some clever code for finding an available port number in Windows to start an instance of the selenium server. This is handy when you are trying to start multiple instances of selenium and need port numbers that are not in use.

Selenium RC Command LIne Help

Type the following command on the command prompt to get a list of arguements the Selenium server command line supports

java -jar selenium-server.jar -h

DRUPAL: How to use Rules to create child nodes from parent and populate child fields from parent fields

I use the Drupal content management system as a companion to the Selenium automation tools so that I get robust reporting and data manipulation. I also use it to perform parameterized data driven test scripts.

Select a check-box where the label contains text

Here was the GUI:

Here was the code behind:

Storing results into an array and writing them to a form later

Here is how I am storing results into an array to read them in a test case at the end of the suite:

Here is how I call the data later and write to a report web form:

How to create a basic PHP-based web service

I borrowed from this page (http://davidwalsh.name/web-service-php-mysql-xml-json) information on how to create a basic PHP web-service. See the attached/modified version.

How to write data to a database

Attached are two files used as an example of how to write data to a MySQL database using HTML/PHP.

 

JavaScript to go to browsers home page, not baseurl

Here is the javaScript to to have the IDE go to the browsers configured home page:

runScript | window.home();

How to Encypt & Decrypt using Javascript & Selenium IDE

This article explains how to encrypt & decrypt with JavaScript and the Selenium IDE. You will need the attached user-extension.js installed, which was created from this article: https://code.google.com/p/crypto-js/#AES.

Selenium Server Help Command

Here is the syntax for having the selenium server return help from the command line: java -jar selenium-server-standalone-2.42.2.jar -h

Here is the output from version 2.42.2:

Usage: java -jar selenium-server.jar [-interactive] [options]

Turn OFF window.alert in Firefox

Here is an example of a Firefox security policy that turns OFF javaScript window.alerts for a specific domain:

How to Parameterize and Loop a Batch File

Here is an example of how to parameterize a Selenium RC batch file, and loop through launching whatever number of instances you specify to the command line:

How to round up to the next whole value

<tr>
    <td>storeEval</td>
    <td>${totalCount} / 100</td>
    <td>pagerValue</td>
</tr>
<tr>
    <td>echo</td>
    <td>${pagerValue}</td>
    <td></td>

How to Simulate ENTER key

Here is a way to simulate hitting the enter key after you have gained focus of the field:

How to connect to a database with javaScript

https://github.com/felixge/node-mysql

How to call user-extensions in webdriver

Found an article that indicates to:

 

RC Browser Commands
  • firefox
  • mock
  • firefoxproxy
  • pifirefox
  • chrome
  • iexploreproxy
  • iexplore
  • firefox3
  • safariproxy
  • googlechrome
  • konqueror
  • firefox2
  • safari
  • piiexplore
  • firefoxchrome
Compare the value of two variables

Here is the code I used to compare a variable to an array of values stored in another variable:

<tr>
    <td>storeEval</td>
    <td>'${testList}'.search(${testId})</td>
    <td>result</td>
</tr>

Selenium 1 RC API Document

http://release.openqa.org/selenium-remote-control/0.9.0/doc/java/

Performance Timing with the IDE

Example:

The values are in milliseconds since 1/1/1970

waitForCondition

This is useful for testing AJAX elements have returned:

<tr>
    <td>waitForCondition</td>
    <td>var value = selenium.getText("//textarea[@name='comment']"); value == "" </td>
    <td>10000</td>
</tr>

Turning off the automatic update on Firefox

I recently experienced an issue where Firefox was automatically trying to force an update of Flash even though I had automatic update turned off.

Get Tomorrows Date

Here is a code snippet of how to get tomorrows date:

How to use multiple Firefox profiles at the same time

You can run more than one Firefox profile at one time.

You first need to create a new profile. You need to run the following in the run dialog or command prompt: C:\Program Files\Mozilla Firefox\firefox.exe -profilemanager

Selenium Commands with Examples

This page is awesome and has a list of all Selenium commands with a link to a page with an example: http://software-testing-tutorials-automation....

Using gotoIf AND contains

Here is how you would use a gotoIf where a variable contains a text string:

Add Variables to the User-Extensions.js file

This article shows you how to add variables to the user-extensions.js file for use in your tests. You have to declare a function first, then call that function in your test to access the varaibles.This method can be used in both the IDE and RC versions of the user-extension file.

Selenium Server Command Line Options

...

Selenium Command Reference

 Selenium Reference

 

How to store time

Here is an example of how to store the Unix Epoch time for any number of reasons:

storeEval | new Date().getTime(); | currentTime

You can you this to:

Pages