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
@Test
public void iamfiguringout(){
FirefoxDriver driver = new FirefoxDriver();
Selenium s = new WebDriverBackedSelenium(driver, "http://www.google.com");
Reporter.log("WDBS object created", true);
s.open("http://www.google.co.in/");
Reporter.log("URL opened", true);
String url = "window.open('intl/en/about.html','mywindow');";
s.openWindow("intl/en/about.html", "mywindow");
Reporter.log("new window opened", true);
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.Command;
import org.openqa.selenium.remote.DesiredCapabilities;
@krmahadevan
krmahadevan / SpawnHubViaCode.java
Created July 26, 2011 07:19
This sample shows how to spawn a Grid2 hub via code, attach a webdriver node and RC node to it and run an automation test on this hub
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.grid.internal.utils.GridHubConfiguration;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
@krmahadevan
krmahadevan / webconfig.txt
Last active May 6, 2020 16:26
A JSON configuration file that can be used to spawn a webdriver node.
{
"capabilities":
[
{
"browserName":"firefox",
"acceptSslCerts":true,
"javascriptEnabled":true,
"takesScreenshot":true,
"firefox_profile":"",
"maxInstances":5
@krmahadevan
krmahadevan / AmDependent.java
Created August 19, 2011 02:11
This class demonstrates on how to use AnnotationTransformer as a listener and inject group dependency on runtime. Here the problem statement is there are two classes AmDependent and AmIndependent. These two classes should be run sequentially but the test
import org.testng.annotations.Test;
@Test
public class AmDependent {
public void methodD() {
System.out.println(this.getClass().getSimpleName()
+ ".method D : Thread ID : " + Thread.currentThread().getId());
}
@krmahadevan
krmahadevan / PlayWithPDF.java
Created August 25, 2011 07:18
This sample program helps you work with a pdf file over the net and extract its contents
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.util.PDFTextStripper;
public class PlayWithPDF {
@krmahadevan
krmahadevan / gist:1321719
Created October 28, 2011 05:59
Steps to recreate the sshj issue
1. create a ‘~/.ssh/config’ file with the following content;
#
# All hosts defaults
#
Host *
Protocol 1,2
FallBackToRsh no
ForwardAgent yes
ForwardX11 yes
PasswordAuthentication yes
@krmahadevan
krmahadevan / BugShower.html
Created November 29, 2011 12:13
This is the main html page that is to be loaded
<html>
<body>
<form>
<input type="button" name="clickMe" value="Go" onclick="confirm('Really?');showModalDialog('demo1.html', 'The Page says', 'dialogWidth:370px;dialogHeight:155px;status=no;help=no;border=thin;');"/>
</form>
</body>
</html>
@krmahadevan
krmahadevan / SeleniumStarterListener
Created January 27, 2012 13:15
A Simple listener which takes care of starting and stopping the Selenium Server
package com.test.listeners;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.Reporter;
public class SeleniumStarterListener implements ISuiteListener {
private static SeleniumServer server = null;
@krmahadevan
krmahadevan / ClassWithListener
Created February 3, 2012 07:08
Demo that shows how to make use of Event Firing Web Driver.
package com.test;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.testng.annotations.Test;