Friday, 12 October 2012

Count elements/links on page using webdriver

Sometimes we need to count links on page. Here we are counting the elements on page. We use the same method for any type of element like link, span,button just use html tag of that element in xpath.

import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

Maximize window in selenium/webdriver

By using below methods you maximize window in selenium/webdriver
1.  selenium.windowMaximize();
2.  driver.manage().window().maximize();

3. If above 2 commands doesn't work try the below code.

Refer the below example

Which one is right ?