Skip to content

Instantly share code, notes, and snippets.

View daluu's full-sized avatar

David Luu daluu

View GitHub Profile
@daluu
daluu / Silk4JLibaryNotes1.txt
Created February 13, 2012 05:12
Silk4JLibrary design notes 1 for Robot Framework
The following are some notes on how to develop a Silk4J-based test library for Robot Framework to use the Borland Silk GUI automation tool/library.
Suggest use Silk4J GUI element/object location inline object model (identify object & execute automation all in one line of code):
desktop.<controlType>find("/windowHandleType[@caption='window title']//controlType[@automationId='idName']").commandName();
At the control type descriptor for automation ID, the automation ID is only the required first array index to locating the object/element. As I recall, there can be optional second index after it that further describes the object/element, but I forget it's syntax, but it goes like such of course:
...//controlType[@automationId='idName'][some other identification here]").commandName();
@daluu
daluu / FileDownloader.php
Created August 23, 2012 05:51
PHP example for file downloader with Selenium
<?
/**
* This creates the cookie header string for curl to send when making requests.
* It includes the (PHP) session ID among possibly a few other cookies. This is
* not for use with curl's built-in cookie JAR (CURLOPT_COOKIEJAR) and file
* handling (CURLOPT_COOKIEFILE) options. This is using the curl header
* (CURLOPT_COOKIE) with value of "name1=value1; name2=value2..."
* See http://hasin.me/2007/04/18/cookiejar-in-curl-it-sucks/ and
* http://en.wikipedia.org/wiki/HTTP_cookie for more details.
*
@daluu
daluu / FileDownloader.java
Last active November 19, 2020 10:17
A simple example of downloading file with Java outside of Selenium to workaround Selenium limitation in file downloads.
/* an example of file download in Java w/ minimal amount of code, library imports,
* and object instantiations especially if you wrap/encapsulate code like example below.
* NOTE: sample code has been tested to work but not thoroughly tested. Use at your own risk.
*/
import java.net.*;
import java.io.*;
//be sure to delete file after working with it. filenamePrefix ~ "test_", file extension ~ ".jpg", include the "."
public String downloadFile(String url, String filenamePrefix, String fileExtension) throws Exception{
@daluu
daluu / autosmsDbg.php
Created July 14, 2013 23:33
For debugging jQueryMobile with PHP
<?php
if (!empty($_POST)){
$sentFlag = TRUE;
$smsResponse = "Something sent";
}else{
$sentFlag = FALSE;
$smsResponse = "Nothing sent.";
}
//get carrier list w/ CURL & establish session
$tuCurl = curl_init();
@daluu
daluu / RfLibrariesUsedExternally.php
Created July 15, 2013 01:40
Example code snippets showing how Robot Framework test libraries and remote servers can be used externally with other frameworks and tools like PHPUnit. Note that it only presents code from the PHP side, not the RF remote server & library side, which a RF user/developer should already be familiar with.
<?php
include_once dirname(__FILE__) . '/../Extensions/IXR_Library.php'; //for XML-RPC
//some code to drive browser with Selenium to get to LDAP login point
$client = new IXR_Client('http://localhost:8270/RPC2');
if (!$client->query('run_keyword', 'LDAPLogin', array("yourUserName", "yourPassword"))) {
print 'An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage();
}
/* now code that continues with Selenium after LDAP login completed
using custom AutoIt library (in Perl) served by RF Perl remote server
@daluu
daluu / SafariDriverAlertWorkaroundExample.java
Created September 30, 2013 02:53
SafariDriver alert handling possible workaround using HTTP requests & responses. This may or may not work for you depending on what your application under test does with the alerts.
/* Safari workaround below simply constructs the required HTTP POST data
* as key/value pairs (e.g. param1=value1&param2=value2, etc.)
* then makes an HTTP POST request with that data, then check the received
* HTTP response returned (e.g. status code 200 OK, or response body content contains what you expect)
* Example below currently skips checking response as that part is handled by the CustomHttpClient
* (implementation not shown). Making actual HTTP POST request is same thing. For details on that,
* see this for reference:
* http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests
* http://stackoverflow.com/questions/9129766/urlconnection-is-not-allowing-me-to-access-data-on-http-errors-404-500-etc
*
@daluu
daluu / CartItemObjectsExampleCodeSnippets.java
Last active August 29, 2015 14:06
Selenium page object model to model cart items as objects for testing code snippet examples
// snippet written for and relates to:
// http://autumnator.wordpress.com/2014/09/23/selenium-page-objects-beyond-pages-like-a-cart-object/
/**
* Cart item implementation as a data structure
* containing a related set of WebElements to work with
*
* These cart items reside in and can be extracted from
* shopping cart page object to then be worked with.
**/
@daluu
daluu / PartialSeleniumGridIntegrationWithAutoItExample.java
Last active February 4, 2021 21:32
Partial Selenium Grid integration support with tools like AutoIt, Sikuli, etc.
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.URL;
@daluu
daluu / loadUrlSynchronously.jsx
Created April 8, 2015 22:10
Loads data from a URL in Adobe Illustrator, synchronously! (Uses Bridge behind the scenes)
BridgeTalk.prototype.sendSynch = function(timeout) {
var self = this;
self.onResult = function(res) {
this.result = res.body;
this.complete = true;
}
self.complete = false;
self.send();
if (timeout) {
@daluu
daluu / JSONView Dark Theme.css
Created October 9, 2015 23:21 — forked from timnew/JSONView Dark Theme.css
This is a dark theme for JSONView chrome extension
body {
white-space: pre;
font-family: consolas;
color: white;
background: black;
}
.property {
color: orange;
font-weight: bold;