Skip to content

Instantly share code, notes, and snippets.

View krmahadevan's full-sized avatar
☠️
Threading ain't hard… Locking is!

Krishnan Mahadevan krmahadevan

☠️
Threading ain't hard… Locking is!
View GitHub Profile
@krmahadevan
krmahadevan / GridInfoExtracter.java
Created February 8, 2012 08:25
A utility class that extracts the actual IP and port to which your remote executions are being routed to by Grid2
public class GridInfoExtracter{
private static String[] getHostNameAndPort(String hostName, int port,
SessionId session) {
String[] hostAndPort = new String[2];
String errorMsg = "Failed to acquire remote webdriver node and port info. Root cause: ";
try {
HttpHost host = new HttpHost(hostName, port);
DefaultHttpClient client = new DefaultHttpClient();
@krmahadevan
krmahadevan / LogExtracter
Created July 5, 2012 12:51
Extracts the Logs from a node against which your current test was run
package testng.samples;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
@krmahadevan
krmahadevan / MyConsoleServlet
Created August 9, 2012 09:02
A Grid console servlet, that will provide you with all free and busy proxies along with their registration info as a JSON object
package com.test.MyServlets;
import java.io.IOException;
import java.util.Iterator;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
@krmahadevan
krmahadevan / NodeInfoFromGrid
Created August 9, 2012 09:11
This class shows you how to post against a grid servlet and get information.
package raw.selenium;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
@krmahadevan
krmahadevan / MyProxy
Created August 9, 2012 11:56
This is a custom proxy for the Grid, which will ensure that all the unattended alerts are cleared before the browser is recycled
package com.test.proxy;
import java.net.URL;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.message.BasicHttpRequest;
import org.openqa.grid.common.RegistrationRequest;
@krmahadevan
krmahadevan / EventFiringWebDriverDemo
Created August 24, 2012 06:52
A sample program that shows EventFiringWebDriver doesnt generate events with Actions class
package raw.selenium;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.internal.WrapsElement;
@krmahadevan
krmahadevan / ScreenshotUsingEventFiringWebDriver
Created September 14, 2012 14:33
Generating Screenshots using EventFiringWebDriver and RemoteWebDriver
package raw.code;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
@krmahadevan
krmahadevan / PlayingWithListenerFactory.java
Created September 17, 2012 08:22
How to use ITestNGListenerFactory
package testng.samples;
import org.testng.IExecutionListener;
import org.testng.ITestNGListener;
import org.testng.ITestNGListenerFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/*
@krmahadevan
krmahadevan / EclipseConsoleLogs.txt
Created October 18, 2012 05:16
Sample that shows how to do parallel executions with IE using IEDriverServer.exe
Suites: 0 and:0
[TestNG] Running:
C:\Users\krmahadevan\AppData\Local\Temp\testng-eclipse--361118992\testng-customsuite.xml
[TestRunner] Starting executor for test Default test with time out:2147483647 milliseconds.
bar() running in Thread #11
foo() running in Thread #12
Started InternetExplorerDriver server (32-bit)
2.26.0.6
Listening on port 36943
@krmahadevan
krmahadevan / DemoToShowHowToRunSuitesInParallelViaTestNGAPI.java
Created November 26, 2012 14:58
A sample that shows how to Use the TestNG APIs and run suites in parallel
package testng.samples;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.testng.ITestContext;
import org.testng.TestNG;