Wednesday, April 18, 2012

Grid2 RemoteWebdriver

public class FlipkartBackedGrid2 extends SeleneseTestCase {
private Selenium selenium;
@Parameters({"browser","port"})
@BeforeClass
public void beforeClass(String browser,String port){
DesiredCapabilities capability= new DesiredCapabilities();

capability.setBrowserName(browser);

try {
WebDriver driver= new RemoteWebDriver(new URL("http://localhost:".concat(port).concat("/wd/hub")), capability);
selenium = new WebDriverBackedSelenium(driver, "http://www.flipkart.com");
} catch (MalformedURLException e) {

e.printStackTrace();
}
}

Wednesday, March 7, 2012

IE/Chrome Driver code in Selenium 2.x

private WebDriver driver;

@Before
public void setUp() throws Exception {

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
      ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
driver  = new InternetExplorerDriver(ieCapabilities);
}

--------------------


System.setProperty("webdriver.chrome.driver", "C:\\ChromeDriver\\chromedriver_win_19.0.1068.0\\chromedriver.exe");

driver = new ChromeDriver();

Sunday, September 25, 2011

Adding Main() to JUnit to run from command prompt

//package com.example.tests;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
import junit.framework.*;

public class GE_TC1 extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.ge.com/", "*firefox");
}
public void testGE_TC1() throws Exception {
selenium.open("http://www.ge.com/");
// Search for any word
selenium.type("textToSearch", "energy efficient");
// This is just a comment
selenium.click("searchSubmit");
selenium.waitForPageToLoad("30000");
assertEquals("GE: Search Results", selenium.getTitle());
assertTrue(selenium.isTextPresent("energy efficient"));
}
public static Test suite() {
//method added
return new TestSuite(GE_TC1.class);
}
public void tearDown(){
//Added . Will be called when the test will complete
selenium.stop();
}
public static void main(String args[]) {
// Added. Execution will started from here.
junit.textui.TestRunner.run(suite());
}
}

Sunday, July 24, 2011

Hover Menus

Create a test case with the following steps:
1.Open http://www.annauniv.edu/
2.Click on the Link ‘Departments’
3.From the ‘Faculty of Civil Engineering’ menu, choose ‘Institute for Ocean Management’
4.New page opens, verify for the correct page
5.From the ‘Research Themes’ menu, choose ‘Coastal Pollution Monitoring and Hazards’
6.New page opens, verify for the correct page.

Saturday, July 23, 2011

Screen capture ex

1.Go to the below URL:http://maps.google.com/maps
2.Type or Cut and Paste the below Address:

90 Hamilton Street, Cambridge, MA-02139

1.Verify the Text Present Lim Consultants Inc
3.Click on the Lim Consultants Inclink
4.VerifyText Present “limconsultants.com” on the right side inline popup window.
5.AssertText “Lim Consultants Inc” present within the inline popup window.
6.Stop the Recoding in Selenium IDE
7.Capture the screen at the start and end of Test
8.Save and view the screen shots

Sunday, July 10, 2011

DDT CSS

css=html.yui3-js-enabled body div.page-content-wrapper section.page-content div#SearchResults-1.SearchResults ul.result-set li#search-result0.result div.main section p.title a.subtle span.name

DDT CSS

css=html.yui3-js-enabled body div.page-content-wrapper section.page-content div#SearchResults-1.SearchResults ul.result-set li#search-result0.result div.main section p.title a.subtle span.name