Posts

Webdriver - Set browser width and height

Selenium WebDriver allows resizing and maximizing window natively from its API. We use 'Dimension' class to resize the window. Lets take the help of Selenium WebDrivers Dimension Class and declare object say 'd' by initializing it with width and height as 420X600 as shown below: Remember, We need to import the statement 'import org.openqa.selenium.Dimension' import org.openqa.selenium.Dimension; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class browser { @Test public void openBrowserwithGivenDimension () { WebDriver driver = new FirefoxDriver(); driver.navigate().to( " http://google.co.in" ); System.out.println(driver.manage().window().getSize()); Dimension d = new Dimension( 420 , 600 ); //Resize the current window to the given dimension driver.manage().window().setSize(d); } } We can set the size and perform testing with lo

How to install TestNG in Eclipse

Image
Steps to follow:           1)   Launch the Eclipse IDE and from Help menu, click “ Install New Software ”. 2) You will see a dialog window, click “ Add ” button. 3) Type name as you wish, lets take “ TestNG ” and type “ http://beust.com/eclipse/ ” as location. Click OK. 4) You come back to the previous window but this time you must see TestNG option in the available software list. Just Click TestNG and press “ Next ” button. 5) Click “ I accept the terms of the license agreement ” then click  Finish . 6) You may or may not encounter a Security warning, if in case you do just click  OK . 7) Click  Next  again on the succeeding dialog box until it prompts you to Restart the Eclipse. 8) You are all done now, just Click  Yes . 9) Proceed with your workplace. 10) After restart, verify if TestNG was indeed successfully installed. Right click on you pr

Webdriver Element Locator

Image
Finally, this tool will provide good element locators for you quickly, for you to use in your test. Generally, I use this tool first, and then Firepath if this tool can’t find a unique way to identify the element I want. To install:  Open Firefox and search for “webdriver element locator”. The first hit should be for  addons.mozilla.org  again–install the addon into Firefox from there, and it’ll be available to you to use later.

How to skip the SSL certificate check in selenium webdriver ?

//Using Firefox profile set AcceptUntrustedCertificates to ture  
 FirefoxProfile profile=new FirefoxProfile();  profile.setAcceptUntrustedCertificates(true);  //Then pass that profile while creating Firefox driver  WebDriver Driver = new FirefoxDriver(profile);