RemoteWebDriver Server

Selenium RemoteWebDriver Server

Download: http://www.seleniumhq.org/download/

Run:
java -jar download file name

WebDriver Hub:
http://127.0.0.1:4444/wd/hub/static/resource/hub.html

sample

package selenium.io;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Keys;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class RemoteWebDriverExam {
       public static void main(String[] args){

              DesiredCapabilities capabilities = new DesiredCapabilities();
              capabilities.setBrowserName("chrome");
              //capabilities.setBrowserName("firefox");
              //capabilities.setBrowserName("internet explorer");

              RemoteWebDriver remoteWD = null;         
              try {
                     remoteWD = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"),capabilities);
              } catch (MalformedURLException e) {
                     e.printStackTrace();
              }

              remoteWD.get("http://www.google.com/ncr");
              WebElement element = remoteWD.findElement(By.name("q"));
              element.sendKeys("Packt Publishing");
              element.sendKeys(Keys.ENTER);
       }
}
Advertisements

[Selenium] Maxmize Web Browser Window Size

[Tips For Selenium]

Maxmize Web Browser Window Size

Firefox & IE

System.setProperty("webdriver.gecko.driver", "C:/webdriver/geckodriver64.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();

Chrome

ChromeOptions co = new ChromeOptions();
co.addArguments("--start-maximized");

System.setProperty("webdriver.chrome.driver", "C:/webdriver/chromedriver.exe");
WebDriver driver = new ChromeDriver(co);

Screen Capture

Chrome

Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
Robot robot = new Robot();
BufferedImage bufferedImage = robot.createScreenCapture(captureSize);
File file = new File("c:\\webdriver\\capturedImages\\capture1.png");
ImageIO.write(bufferedImage, "png", file);