TESTEVERYTHING

Friday 10 August 2012

Selenium Webdriver 2 Wait /Sleep for time period/wait next step execution/ Set speed for next execution

Some times we have to wait while running the script like for next execution wait for specific duration.But in web driver 2, I did not find the simple way to wait for next step execution after that I have decided to use simplest way to wait in looping statement. I have created a method just call the method with waiting time in seconds.It will wait for given time period.


Thursday 9 August 2012

Handling Security Cerificates(UntrustedSSLCertificates) using WebDriver(selenium2)

Handling Security Cerificates(UntrustedSSLCertificates) in Internet Explorer (IE) using WebDriver(selenium2)

driver = new InternetExplorerDriver();
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
// or using selenium rc
selenium.runScript("document.getElementById('overridelink').click()");

Handling Security Cerificates(UntrustedSSLCertificates) in Firefox using WebDriver(selenium2)


Thursday 2 August 2012

Set cookies with domain using webdriver

using web driver I have created the script for adding the cookies using domain. Basically here is the things that you must know first open the URL then add the cookies after that again open the URL now it will add.

 ______________________________________________________
package webdriver;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;

public class RuntestCase {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
       
       
        WebDriver driver;


        System.out.println("firefox");

        DesiredCapabilities capability = DesiredCapabilities.firefox();

        String appUrl = "http://beta.abc.com/mlb/sweepstakes/y2012/sd/alaska_form.jsp";

        capability.setBrowserName("firefox");
        capability.setPlatform(org.openqa.selenium.Platform.ANY);
        driver = new FirefoxDriver(capability);

        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
       
        driver.get(appUrl);

        Calendar c = new GregorianCalendar();
        int year = 2014;
        int month = 6;
        int day = 7;
        int hour = 10;
        int minute = 26;
        int second = 47;
        c.set(year, month, day, hour, minute, second);
        Date expiry = c.getTime();
        String name = "betaaccess";
        String value = "true";
        String domain = ".abc.com";
        String path = "/";
        Cookie cookie = new Cookie(name, value, domain, path, expiry, false);
        driver.manage().addCookie(cookie);
        driver.get(appUrl);
               
            }
    }

Which one is right ?

Translate







Tweet