Sunday, 2 February 2014

Difference between Frame and IFrame in html



http://www.differencebetween.info/difference-between-frame-and-iframe

Selenium WebDriver, Running scripts in Firefox,chrome,safari and IE browsers in a Remote Machine



For Firefox browser :

1. Download selenium-server-standalone-2.*.jar from http://docs.seleniumhq.org/download/
2. Run the following command java -jar < downloaded jar filepath>in remote machine.
3. Then run the following java code from the machine from which you are going to initiate the remote machine.
import java.io.File;
import java.net.URL;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
public class SeleniumTest {
public static void main(String args[]) throws Exception {
URL url = new URL( "http", "", 4444, "/wd/hub" );
//Note : If you give localhost in remote machine address place then your machine acts as remote machine
DesiredCapabilities capabilities =DesiredCapabilities.firefox();
RemoteWebDriver driver = new RemoteWebDriver(url ,capabilities );
driver.get("http://google.com");
driver.findElement(By.name("q")).sendKeys("java");
driver.quit();
}
}



For safari browser :

1. Download selenium-server-standalone-2.*.jar from http://docs.seleniumhq.org/download/
2. Run the following command java -jar < downloaded jar filepath>in remote machine.
3. Then run the following java code from the machine from which you are going to initiate the remote machine.

import java.io.File;
import java.net.URL;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
public class SeleniumTest {
public static void main(String args[]) throws Exception {
URL url = new URL( "http", "", 4444, "/wd/hub" );
//Note : If you give localhost in remote machine address place then your machine acts as remote machine
DesiredCapabilities capabilities =DesiredCapabilities.safari();
RemoteWebDriver driver = new RemoteWebDriver(url ,capabilities );
driver.get("http://google.com");
driver.findElement(By.name("q")).sendKeys("java");
driver.quit();
}
}




For chrome browser :

1. Download selenium-server-standalone-2.*.jar from http://docs.seleniumhq.org/download/ and chromedriver.exe file from https://code.google.com/p/chromedriver/downloads/list
2. Run the following command java -Dwebdriver.chrome.driver=\chromedriver.exe -jar < downloaded jar filepath> in remote machine.
Note : if you are already running firefox in 4444 port then try to execute chrome in other port
Example : java -Dwebdriver.chrome.driver=\chromedriver.exe -jar < downloaded jar filepath> -port 5555
3. Then run the following java code from the machine from which you are going to initiate the remote machine.

import java.io.File;
import java.net.URL;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
public class SeleniumTest {
public static void main(String args[]) throws Exception {
URL url = new URL( "http", "", 4444, "/wd/hub" );
//Note : If you give localhost in remote machine address place then your machine acts as remote machine
//Note : If you give 5555 as port number in remote system,url should be changed as below
// Example : URL url = new URL( "http", "", 5555, "/wd/hub" );
DesiredCapabilities capabilities =DesiredCapabilities.chrome();
RemoteWebDriver driver = new RemoteWebDriver(url ,capabilities );
driver.get("http://google.com");
driver.findElement(By.name("q")).sendKeys("java");
driver.quit();
}
}




For IE browser :

1. Download selenium-server-standalone-2.*.jar from http://docs.seleniumhq.org/download/ and iedriverserver.exe file from https://code.google.com/p/selenium/wiki/InternetExplorerDriver
2. Run the following command java -Dwebdriver.ie.driver=\iedriverserver.exe -jar < downloaded jar filepath> in remote machine.
Note : if you are already running firefox in 4444 port then try to execute IE in other port
Example : java -Dwebdriver.ie.driver=\iedriverserver.exe -jar < downloaded jar filepath> -port 5555
3. Then run the following java code from the machine from which you are going to initiate the remote machine.

import java.io.File;
import java.net.URL;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
public class SeleniumTest {
public static void main(String args[]) throws Exception {
URL url = new URL( "http", "", 4444, "/wd/hub" );
//Note : If you give localhost in remote machine address place then your machine acts as remote machine
//Note : If you give 5555 as port number in remote system,url should be changed as below
// Example : URL url = new URL( "http", "", 5555, "/wd/hub" );
DesiredCapabilities capabilities =DesiredCapabilities.internetExplorer();
RemoteWebDriver driver = new RemoteWebDriver(url ,capabilities );
driver.get("http://google.com");
driver.findElement(By.name("q")).sendKeys("java");
driver.quit();
}
}