Skip to content

Instantly share code, notes, and snippets.

View tarun3kumar's full-sized avatar

Tarun Kumar tarun3kumar

View GitHub Profile
@tarun3kumar
tarun3kumar / loginuser.csv
Created January 21, 2015 10:35
CSV data file used in test plan
user1@testmail.com 123456
user2@testmail.com 654321
@tarun3kumar
tarun3kumar / updatesauceLabsresults.java
Created January 3, 2012 19:20
Update SauceLabs Results using Selenium2/WebDriver
@AfterMethod(alwaysRun = true)
public void shutDownDriver(ITestResult result) throws IOException {
// Update SauceLabs result
if(testbed.equals("saucelab")) {
String jobID = ((RemoteWebDriver)driver).getSessionId().toString();
SauceREST client = new SauceREST("username", "key");
Map<String, Object>sauceJob = new HashMap<String, Object>();
sauceJob.put("name", "Test method: "+result.getMethod().getMethodName());
if(result.isSuccess()) {
@tarun3kumar
tarun3kumar / softassertion.java
Created January 4, 2012 06:52
Soft Assertion
package com.yahoo.test.library;
import org.testng.Assert;
import org.testng.Reporter;
import com.thoughtworks.selenium.SeleneseTestBase;
public class CustomVerification extends SeleneseTestBase {
private StringBuffer verificationErrors;
@tarun3kumar
tarun3kumar / usingcustomverification.java
Created January 4, 2012 06:59
Using Custom Verification
@Test(groups="non-grid", alwaysRun=true)
public void verifyTaggedBlogs() throws InterruptedException {
customVerification.verifyTrue(actualblogTag.equalsIgnoreCase(expectedBlogtag.trim()), "Expected Blogs with tag: " +expectedBlogtag+
", While actual tag is: " +actualblogTag);
customVerification.verifyTrue(selenium.isElementPresent(getPageElement("BlogsHomePage", "NTad")),
customVerification.verifyTrue(selenium.isElementPresent(getPageElement("BlogsHomePag
customVerification.checkForVerificationErrors();
}
@tarun3kumar
tarun3kumar / retrievedynamicobjectsselenium.java
Created January 4, 2012 07:06
Retrieve Dynamic Objects from Seleneium
/**
* Provides object ids or name for HTML object input
*
* @param inputType Could be checkbox, TextBox or Radio button
* @return objectId
*
*/
public static String[] getInputObjects(String inputType) {
StringBuilder sb = new StringBuilder("var objectId = [];")
@tarun3kumar
tarun3kumar / seleniumc#test.cs
Created January 4, 2012 06:46
Selenium C# test
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
@tarun3kumar
tarun3kumar / waitforcondition.java
Created January 5, 2012 17:56
Using selenium waitForCondition method
public class LoginTest {
@Test
public void testLogin() {
login(userName, userPassword);
waitForCondition("selenium.isElementPresent(\""+UserDashboard.getDashboardLocator()+"\")", "60000");
// Some assertion here
}
}
class UserDashboard {
@tarun3kumar
tarun3kumar / SeleniumForHuman.groovy
Created February 1, 2012 06:24
Comprehensible Selenium Tests
scenario "Searching restaurant in your Bangalore", {
given "the user is on the Google home page", {
end_user.is_the_google_home_page()
}
when "the end user types restaurant in search box", {
end_user.searches_for "restaurant"
}
then "they should location listing for 'BBQ Nation", {
end_user.should_see_search_result_page_with_word "BBQ Nation"
}
@tarun3kumar
tarun3kumar / HeadlessFF.java
Created April 26, 2012 10:55
Executing Headless test in Firefox driver
public static void main(String[] args) throws IOException {
// Setup firefox binary to start in Xvfb
String Xport = System.getProperty(
"lmportal.xvfb.id", ":1");
final File firefoxPath = new File(System.getProperty(
"lmportal.deploy.firefox.path", "/usr/bin/firefox"));
FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath);
firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
@tarun3kumar
tarun3kumar / JMeterProjectFile
Last active September 16, 2016 11:55
JMeter project file, used in performance tetsing projects at - http://www.seleniumtests.com/p/performance-testing-videos.html
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.9" jmeter="3.0 r1743807">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="APP_URL" elementType="Argument">