Monday 30 September 2013

How to avoid full page load | Webdriver

Clicking an Element on page load is even possible on webdriver; By default, webdriver wait for the entire page to load and then picks the element. The links and texts are visible but they are not clickable; However, it works well on Selenium IDE picking elements on page load.

Webdriver make use of the FirefoxProfile to avoid such risks; It's applicable only for Firefox browser.

FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("webdriver.load.strategy", "unstable");
driver = new FirefoxDriver(fp);
baseUrl = "http://xyz.com";
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

driver.navigate().to("http://xyz.com");
driver.findElement(By.xpath(Value)).click();
System.out.println("Button got clicked");

Thursday 26 September 2013

JavaScript Selenium script Validation - WPM [BrowserMob]

Configure Neustar Script Recorder

1| Log into WPM
2| Scripting > Scripting Overview
3| Install the Neustar Script Recorder "(xpi)
4| Launch Selenium IDE
5| Click menu Neustar > Options... [Obtain API Key and API Secret using WPM profile]
6| Go to 'My Account'.
7| Click Users > Manage 
8| Get API details and fill up Neustar connection options
9| Upload the scripts to WPM from Selenium IDE | 'Upload to Neustar' icon next to 'Click to Record'
10| Scripting > Scripting Overview
11| Click on Untitled and copy the js script generated.
12| Create a new text file & paste the script
13| Save as .js format. e.g., html.js


JavaScript validator

1| Download local-validator
2| Unzip on location C:\local-validator\local-validator-4.11.57
3| Go to C:\Users\username
4| Create a file config.properties.txt
5| Paste the following and save it
FF=C:\\Program Files\\Mozilla Firefox\\firefox.exe
6| Open cmd prompt
7| Move to validator bin folder
C:\local-validator\local-validator-4.11.57\bin>validator.bat D:\html.js -browser FF
8| Click enter to execute the Javascript file.

Tuesday 24 September 2013

Simple Java Tips | Selenium Uses

1| Handling Exception | Assertion

Multiple Catch Blocks
Multiple catch avoid quit tests from various Exception

try
{
   assertEquals(actual, expected);
}catch(Exception e)
{
   System.out.println("...");
}catch(NullPointerException e)
{
   System.out.println("...");
}catch(IOException e)
{
   System.out.println("...");
}catch(ComparisonFailure e)
{
   System.out.println("...");
}


Finally Keyword
The finally keyword always executes

try
{
   assertEquals(actual, expected);
}catch(Exception e)
{
   System.out.println("...");
}finally
{
   System.out.println("...");
}


2| Java Arrays

Store values as a list of arrays for assertion.

#1
List<WebElement> savedItem = driver.findElement(By.id(Value)).findElements(By.tagName("li"));
ArrayList<String> storelist = new ArrayList<String>();
for(int i=0; i<savedItem.size(); i++) 
{
String d = savedItem.get(i).findElement(By.id(Value)).getText();
storelist.add(d);
System.out.println(storelist.get(i));
}

#2
String content[]={"string1","string2","string3","string4","string5"};
for(int i=0; i<content.length; i++){
if(isElementPresent(By.cssSelector("ul#"+content[i]+" > li")))
{
// Perform your code
}


3| Date Format

Date Format can be asserted using Java DateFormat.

String element = driver.findElement(By.xpath(Value)).getText();    
String Result = element.substring(6);
System.out.println(Result);   
    
DateFormat format = new SimpleDateFormat("MMM dd, yyyy");  // Date Format can be modified link
Date dif = format.parse(Result);
System.out.println(dif);

_
Sep 4, 2013
Wed Sep 04 00:00:00 IST 2013


4| Random Select

Elements can be selected randomly using Random().

List<WebElement> element = driver.findElement(By.id(Value)).findElements(By.tagName("li"));
    
Random r=new Random();
int index = r.nextInt((element.size()-1)-0+1)+0;  // int index = r.nextInt(max - min + 1) + min;    
String id = element.get(index).getAttribute(Value);
System.out.println(id);


5| Sort Arraylist

Elements can be sorted either in ascending order or descending order.

List<WebElement> savedItem = driver.findElement(By.id(Value)).findElements(By.tagName("li"));
ArrayList<String> storelist = new ArrayList<String>();
for(int i=0; i<savedItem.size(); i++) 
{
String d = savedItem.get(i).findElement(By.tagName("a")).getText();
storelist.add(d);
System.out.println(storelist.get(i));
}

Collections.sort(storelist); // Ascending order
System.out.println(storelist);
Collections.reverse(storelist); // Descending order

Java String | Selenium Uses

Java String methods examples based on the string,
String a = "This is some copy welcoming the user to this section and explaining what they can expect to find here.";

1|  substring()
Truncates text till string length 24
String Result = a.substring(24);
_
ing the user to this section and explaining what they can expect to find here.

Truncates text after string length 24
String Result = a.substring(0, 24);
_
This is some copy welcom


2|  toUpperCase()
Converts string to Uppercase
String Result = a.toUpperCase();
_
THIS IS SOME COPY WELCOMING THE USER TO THIS SECTION AND EXPLAINING WHAT THEY CAN EXPECT TO FIND HERE.


3|  toLowerCase()
Converts string to Lowercase
String Result = a.toLowerCase();
_
this is some copy welcoming the user to this section and explaining what they can expect to find here.


4|  concat()
Combines two different strings
String Result = a.concat("Adding this text");
_
This is some copy welcoming the user to this section and explaining what they can expect to find here.Adding this text


5|  replace()
Replace a string with another
String Result = a.replace("some", "few");
_
This is few copy welcoming the user to this section and explaining what they can expect to find here.


6|  replaceFirst()
Replaces the first word from the string
String Result = a.replaceFirst("to", "ot");
_
This is some copy welcoming the user ot this section and explaining what they can expect to find here.


7|  length()
Finds the length of the string
int Result = a.length();
System.out.println(Result);
_
102


8|  charAt()
Finds the letter/char at length location 0
char Result = a.charAt(0);
System.out.println(Result);
_
T


9|  contains()
Checks the specific text in the string
boolean Result = a.contains("some");
System.out.println(Result);
_
true


10|  contentEquals()
verifies that the content matches the string in boolean
boolean Result = a.contentEquals("This is some copy welcoming the user to this section and explaining what they can expect to find here.");
System.out.println(Result);
_
true


11|  endsWith()
verifies that the end of the sentence matches the string in boolean
boolean Result = a.endsWith("expect to find here.");
System.out.println(Result);
_
true


12|  startsWith()
verifies that the start of the sentence matches the string in boolean
boolean Result = a.startsWith("This is some");
System.out.println(Result);
_
true


13|  equals()
verifies that the text matches the string in boolean
boolean Result = a.equals("This is some copy welcoming the user to this section and explaining what they can expect to find here.");
System.out.println(Result);
_
true


14|  equalsIgnoreCase()
verifies the string by ignoring case-sensitive characters in boolean
boolean Result = a.equalsIgnoreCase("THIS IS SOME COPY WELCOMING THE USER TO THIS SECTION AND EXPLAINING WHAT THEY CAN EXPECT TO FIND HERE.");
System.out.println(Result);
_
true


15|  isEmpty()
verifies the string is empty in boolean
boolean Result = a.isEmpty();
System.out.println(Result);
_
false


17|  matches()
verifies that the text matches string in boolean
boolean Result = a.matches("This is some copy welcoming the user to this section and explaining what they can expect to find here.");
System.out.println(Result);
_
true


18|  getBytes()
Encode String
byte[] Result = a.getBytes();
System.out.println(Result);
Decode String
String s = new String(Result);
System.out.println("Text Decrypted : " + s);
_
[B@10deb5f
Text Decrypted : This is some copy welcoming the user to this section and explaining what they can expect to find here.


19|  indexOf()
Finds the index using Character of the string
System.out.print("Found Index : " );
System.out.println(a.indexOf( 'T' ));
System.out.println(a.indexOf( 'h' ));
System.out.println(a.indexOf( 'i' ));
System.out.println(a.indexOf( 's' ));
_
Found Index : 0
1
2
3


20|  compareTo()
Returns 0 for True and 1 for False after string comparison
int Result = a.compareTo("dfg");
System.out.println(Result);
int Result1 = a.compareTo("This is some copy welcoming the user to this section and explaining what they can expect to find here.");
System.out.println(Result1);
_
1 // False
0 // True


21|  compareToIgnoreCase()
Returns 0 for True and 1 for False after string comparison that ignores case-sensitive
String b = "THIS IS SOME COPY WELCOMING THE USER TO THIS SECTION AND EXPLAINING WHAT THEY CAN EXPECT TO FIND HERE.";
int Result = a.compareToIgnoreCase(b);
System.out.println(Result);
_
// True

Monday 23 September 2013

Truncate special characters using Java Patterns | Selenium

Truncating string that holds special characters, !@#$%^&*(){}[]? made easy using Java patterns on Selenium.
For Example, take a string (4000).  Here,
Actual Result: string (4000) | Expected Result: integer 4000

1| remove parentheses
2| convert string to integer

List<WebElement> count = driver.findElement(By.cssSelector("Value")).findElements(By.tagName("li"));
//getting iTable count    
String a = count.get(0).findElement(By.cssSelector("Value")).getText();

Pattern pt = Pattern.compile("[()]"); \\ special characters can be of anything  !@#$%^&*(){}[]?
Matcher match= pt.matcher(a);
while(match.find())
{
    String s= match.group();
    a=a.replaceAll("\\"+s, ""); \\ remove parentheses
}

System.out.println("Total count in string: " + a);

int value = Integer.parseInt(a); \\ convert string to integer


Example |2|

WebElement element = driver.findElement(By.xpath("Value"));    
String truncelem = element.getText();
String result = truncelem.replaceAll("[()]","");

Sunday 22 September 2013

IsElementPresent()

There are various reasons and essential for this special functionality for everyday selenium-users.

isElementPresent() // positive test case
#1
if(isElementPresent(By.cssSelector(Value)))
System.out.println("...");
else
System.out.println("..."); 

#2 
Checks the availability using size()
if(driver.findElements(By.id("Value)).size()>0)
{
   System.out.println("...");
}else 
{
   System.out.println("...");
}

!isElementPresent() // negative test case
if(!isElementPresent(By.xpath("Value")))
{
   System.out.println("...");
else
{
   System.out.println("...");
}


isDisplayed() - Alternate for isElementPresent()

isDisplayed() is used for verifying whether an element is available on the page or not.

driver.findElement(By.xpath(Value)).isDisplayed();

Zoom in & Zoom out [Windows | MAC]

Zoom in
WebElement html = driver.findElement(By.tagName("html"));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));

Zoom out
WebElement html = driver.findElement(By.tagName("html"));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT));

Zoom 100%
WebElement html = driver.findElement(By.tagName("html"));
html.sendKeys(Keys.chord(Keys.CONTROL, "0"));

Zoom Feature on MAC
WebElement html = driver.findElement(By.tagName("html"));
html.sendKeys(Keys.chord(Keys.COMMAND, Keys.ADD));
html.sendKeys(Keys.chord(Keys.COMMAND, Keys.SUBTRACT));
html.sendKeys(Keys.chord(Keys.COMMAND, Keys."0"));

Thursday 19 September 2013

Python | Eclipse | PyDev | Selenium

Configure PyDev in Eclipse

1| Install PyDev plugin in Eclipse
Help > Install New Software...
2| Click Add and type http://pydev.org/updates
3| Select the check box, 'PyDev' and press Next.

Note:
By default, Aptana Studio has inbuilt PyDev installed; Other steps are similar to Eclipse.



4| Go to Windows > Preferences > Interpreter - Python


5| Click on 'New' and Locate python.exe  "C:\Python27\python.exe"




6| Create a New Python Project  
Right click on package Explorer > New > others
7| Type 'PyDev Project'.
8| Select 'PyDev Project' and press Finish.


9| Create a new Python package.


10| Create a new PyDev module.
Right click on package > New > PyDev module



11| Develop your python selenium script and execute Tests ;)


Wednesday 18 September 2013

Log4j | Selenium

Configure log4j

1| Download log4j.jar  and add into build path
2| Open src folder under project
3| Create a new text file.
4| Paste the following..

#Application Logs
log4j.logger.devpinoyLogger=DEBUG, dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.maxFileSize=5000KB
log4j.appender.dest1.maxBackupIndex=3
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %c %m%n
log4j.appender.dest1.File=\logs\\SeleniumLogs.log
#do not append the old file. Create a new log file everytime
log4j.appender.dest1.Append=true


5| Save it with an extension, '.properties'. e.g., log4j.properties
6| Now, log through the script as shown below.

public class classname {
private static Logger Log = Logger.getLogger(classname.class);

@BeforeTest
public void setUp() throws Exception {
Log.info("_______started server_______");
Log.warn("Warn");

baseUrl = "https://yourwebsite.com";   
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
   
@Test
public void testAbi() throws Exception {
driver.get(baseUrl + "/web/browse.v");
Log.info("_______Test Inprogress_______");
}
   
@AfterTest
public void tearDown() throws Exception {   
Log.info("_______Stopping server_______");

driver.quit();
}
}


6| Execute the test and check the log file, SeleniumLogs.log under logs folder.

Sunday 15 September 2013

Store Auto-suggestions using iterator | Webdriver

Identifying auto-suggestion lists and storing them can be achieved using iterator. Couple of examples shown below demonstrate iterators and their use on auto-complete.

e.g.,
1|
driver.get(baseUrl+"http://www.indiabookstore.net/");
driver.findElement(By.id("searchBox")).sendKeys("sam");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  
WebElement table = driver.findElement(By.className("acResults"));
List<WebElement> rowlist = table.findElements(By.tagName("li"));
System.out.println("Total No. of list: "+rowlist.size());
Iterator<WebElement> i = rowlist.iterator();
System.out.println("Storing Auto-suggest..........");
while(i.hasNext())
{
  WebElement element = i.next();
  System.out.println(element.getText());
}


2|
driver.get(baseUrl+"https://www.google.co.in/");
driver.findElement(By.id("gbqfq")).sendKeys("Sams"); 
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
   
WebElement table = driver.findElement(By.className("gssb_m"));     
List<WebElement> rows = table.findElements(By.tagName("span")); 
System.out.println("Total no. of rows: "+ rows.size());
Iterator<WebElement> i = rows.iterator();  
while(i.hasNext()) {  
  WebElement row = i.next();  
  System.out.println(row.getText());

Thread.sleep(4000);
rows.get(1).click();
Thread.sleep(5000);



Alternate Concept for iteration


List<WebElement> listitems = driver.findElements(By.id("value"));
for(WebElement temp: listitems) // temp is the declared variable name
{
System.out.println((temp.findElement(By.tagName("value")).getText()));   
}

Friday 13 September 2013

Python | Selenium

Python set up

1| Download and install Python 2.7

pip is a package management system,  a tool for installing and managing Python packages. easy_install is similar to pip.

Configure easy_install
   2.1| Install setuptools | Windows 32-bit machine 
   2.2| If you're using Windows 64-bit machine, save this ez_setup.py file in local directory and run it.

Configure pip
   3| Save this get-pip.py file into local directory and run it.

4| Install Selenium Python Client Driver
    a| Open cmd prompt
    b| Locate the folder C:\Python27\Scripts in cmd and enter
easy_install selenium
or|
pip install selenium


5| Generate scripts from Selenium IDE.
6| Export Test case as Python 2 / unittest / WebDriver
7| Double click on .py file and execute python test.


Selenium Update for Python

1| Open cmd prompt
2| Locate the folder C:\Python27\Scripts in cmd and enter
pip install -U selenium
or|
pip install selenium==2.40
or|
easy_install -U selenium
3| Setup tools can also be updated [only if needed].
pip install --upgrade setuptools



Thursday 12 September 2013

Basic Selenium Functions for Newbies

This section is for newbies about selenium webdriver. There will be frequent updates on this.

close()
Closes current active window.
driver.close();

#PYTHON
self.driver.close()

#RUBY
@driver.close



quit()
Quits the driver and closes every windows.
driver.quit();

#PYTHON
self.driver.quit()

#RUBY
@driver.quit



getTitle()
Get the current page title.
driver.getTitle();

#PYTHON
#1 | print page title
print driver.title
#2 | assert text in the page_title
assert "your text" in driver.title
#3 | assert text in the page_title
self.assertIn("your text", driver.title) 
#4 | assert page_title
self.assertEquals("your page_title", driver.title, "Asserting Title")

#RUBY
#1 | print page title
puts @driver.title
#2 | assert page_title
assert_equal('your text', @driver.title)



getPageSource()
Retrieves all the page source.

#1 | print page_source of a web page
System.out.println(driver.getPageSource());
#2 | assert text in a web_page
driver.getPageSource().contains("your text");
#3 |
boolean b = driver.getPageSource().contains("your text");
assertTrue(b); 
#4 |
Boolean b =  driver.getPageSource().contains("your text");
System.out.println(b);

#PYTHON
#1 | print page_source of a web page
print driver.page_source
#2 | assert text in a web_page
assert "your text" in driver.page_source

#RUBY
#1 | print page_source of a web page
puts @driver.page_source
#2 | assert text in a web_page
assert(@driver.page_source.include?("your text"))



findElement()
Finds first element within the current page. 
WebElement element = driver.findElement(By.xpath("//div[@class='google-header-bar']"));



findElements()
Finds all the elements within the current page.

1| Store Length
driver.get("https://accounts.google.com/");
List<WebElement> scriptcount = driver.findElements(By.xpath("//script[@type='text/javascript']"));
System.out.println("Overall textboxes: "+scriptcount.size()); 

2| Click Element
driver.get("http://www.indiabookstore.net");
driver.findElement(By.id("searchBox")).sendKeys("Alche");
List <WebElement> listItems = driver.findElements(By.xpath("/html/body/div[4]/ul/li"));
listItems.get(0).click();

3| Track by TagName
List<WebElement> link = driver.findElement(By.id("Value")).findElements(By.tagName("li"));

Wednesday 11 September 2013

Selenium Builder | Running selenium scripts on Cloud


Selenium Builder is similar to Selenium IDE. It has special credits like running cross-browser tests on Cloud directly from IDE. Exporting selenium scripts in Java/TestNG/Webdriver combination is feasible on Selenium Builder.

1| Create an account on Sauce and obtain the access key
2| Install the Addon, Selenium Builder in Firefox web browser
3| Open the webpage under test
4| Right click on the page > Launch Selenium Builder
5| Click Selenium 1 | Selenium 2
6| Record selenium scripts
7| Go to 'Run' menu
8| Click 'Run on Sauce OnDemand'
9| Enter the Sauce Username and Access Key
10| Choose the Browser and OS combinations for test execution.



11| Log into Sauce and verify the test results.

Handling Captcha | Webdriver

Make use of the 'input' tag with type 'hidden' in-order to handle Captcha.

Look at this example for reference..


driver.get("http://www.google.com/recaptcha/learnmore");
driver.switchTo().frame(0); //calling iframe with no id
JavascriptExecutor js = (JavascriptExecutor) driver; 
//Setting the captcha values 
js.executeScript("document.getElementsByName('recaptcha_challenge_field')[0].setAttribute('value', '03AHJ_Vuv4tV3FrmUHbImL9JPkWJNqs1KDbFdKfG1jhqa2Uhl4U1vzLxXtZMMkZoAHuVCXA1js3GiaaQJ-zqyuledzZP-PEOV-y_Fx87-U6HVu4nh8kfwPzfPU50yEV5oscb20ptwMGR5EEoAtE8dfAlwCVejJtP779upzfAqn_ID5IQJ2F9Nw218')");
driver.findElement(By.name("recaptcha_response_field")).sendKeys("23129555894");
driver.findElement(By.name("Button1")).click();


Note: setAttribute plays a major role here.

Sunday 8 September 2013

Handling Windows using AutoIt | Selenium


Configure AutoIt with Selenium script

1| Download AutoIt Full Installation and install
2| Create a new file with extension .au3 | Open a folder Right click > AutoIt v3 Script
3| Right click the file > Edit Script
4| Remove all the scripts (if present)
5| Select Tools > AU3Recorder [record and playback]
6| Select all the 3 check box before recording
7| Press 'Click To Record'
8| After recording, try to edit/remove the function name that starts with an underscore '_' (from script). ie., _AU3RecordSetup()
9| Right click the file > Compile Script
10| An executable file .exe will be generated and ready for integration with Selenium
11| Call the Autoit script, file.exe in Selenium script as shown below,

Runtime.getRuntime().exec("C:\\Users\\Sams\\Desktop\\create.exe");

Note:- 
#1 Install SciTE, SciTE4AutoIt3.exe if the option, AU3Recorder found missing under tools menu.
#2 Sometimes issues like. "The program can't start because MSVCR100.dll is missing from your computer." may appear. Try installing,
Microsoft Visual C++ 2010 Redistributable Package (x86) (or)
Microsoft Visual C++ 2010 Redistributable Package (x64)
based on your machine support for fix.
#3 Autoitscript Functions

Wednesday 4 September 2013

Keys in Selenium script | Webdriver

Key combinations made easier through Actions. Some of the popular keys were illustrated in this section; Similar key functions can be used for other keys from the image.

Enter/Return
driver.findElement(By.id("Value")).sendKeys(Keys.RETURN);
or|
driver.findElement(By.id("Value")).sendKeys(Keys.ENTER);

#PYTHON
from selenium.webdriver.common.keys import Keys
driver.find_element_by_name("Value").send_keys(Keys.RETURN)
or|
element = driver.find_element_by_id("Value")
element.send_keys("keysToSend")
element.submit()

#RUBY
element = @driver.find_element(:name, "Value")
element.send_keys "keysToSend"
element.submit
or|
element = @driver.find_element(:name, "Value")
element.send_keys "keysToSend"
element.send_keys:return


Down Arrow
driver.findElement(By.id("Value")).sendKeys(Keys.ARROW_DOWN);


TAB
Actions action =new Actions(driver);
action.sendKeys(Keys.TAB).sendKeys("keysToSend");
action.build().perform();

#PYTHON
driver.find_element_by_name("Value").send_keys(Keys.TAB)


Ctrl+End | Scroll to Bottom of the page
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();


Backspace
Actions actions = new Actions(driver);
actions.sendKeys(Keys.BACK_SPACE).perform();

#PYTHON
driver.find_element_by_name("Value").send_keys(Keys.BACKSPACE)
or|
driver.find_element_by_name("Value").send_keys(Keys.BACK_SPACE)




#PYTHON




Xpath Patterns for Locating WebElements


contains()
Elements can also be located using partial text from an attribute value.
i.e., any attribute, class/id has value: say,  'your class is here';  Here, you can make use of contains for locating elements with partial text, 'your class' truncating 'is here'.
1|
//input[contains(@class, 'your partial class')]
2|
//input[contains(text(),'your partial text')]


not(contains())
'not contains'  is just the reverse of  'contains'. 
1|
//input[not(contains(@class, 'your class'))]

Excercise |1|
<ul id="subject">
   <li class="root">
      <a id="abc">"Physics"</a>
   </li>
   <li class="root">
      <a id="abcd">"Chemistry"</a>
   </li>
   <li class="root">
      <a id="abcde">"Mathematics"</a>
   </li>
</ul>

List<WebElement> elements = driver.findElements(By.xpath("//ul[@id='subject']/li[not(contains(.,'Chemistry'))]"));
//driver.findElements(By.xpath("//ul[@id='subject']/li[not(contains(a,'Chemistry'))]")); -Alternate Step
System.out.println(elements.size());

for (int i = 0; i < elements.size(); i++) {
System.out.println(ass.get(i).getText());
}
OUTPUT| 
Physics
Mathematics


text()
The inner text can be used to find Elements.
1|
//input[text()='your text']
2|
//div[contains(text(), 'your text')]


starts-with()
Finds dynamic elements using start of an Element. If your dynamic ids have the format <input id="text-12345" /> where 12345 is a dynamic number you could use the following XPath: //input[starts-with(@id, 'text-')]

Tuesday 3 September 2013

How to do XPath validation ?


1| Access your web page. e.g., 'http://seleniumworks.blogspot.in/'
2| Press F12 key.
3| Again, press Esc key.
4| Enter your xpath inside $x
$x(your xpath)
e.g.,
$x("//div[@class='navbar section']")
5| Press Enter key for output.