My Thoughts: May 2012

Thursday, May 31

WebDriver(Selenium2) : Extract text from PDF file using java


Verifying PDF content is also part of testing.But in WebDriver (Selenium2) we don't have any direct methods to achieve this.

If you would like to extract pdf content then we can use Apache PDFBox  API.

Download the Jar files and add them to your Eclipse Class path.Then you are ready to extract text from PDF file .. :)

Here is the sample script which will extract text from the below PDF file.
http://www.votigo.com/pdf/corp/CASE_STUDY_EarthBox.pdf
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.util.PDFTextStripper;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Reporter;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class ReadPdfFile {
 
 WebDriver driver;
 
  @BeforeTest
  public void setUpDriver() {
   driver = new FirefoxDriver();
   Reporter.log("I am done");
     }
  
  @Test
  public void start() throws IOException{
  driver.get("http://votigo.com/overview_collateral.pdf");
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  URL url = new URL(driver.getCurrentUrl()); 
  BufferedInputStream fileToParse=new BufferedInputStream(url.openStream());

  //parse()  --  This will parse the stream and populate the COSDocument object. 
  //COSDocument object --  This is the in-memory representation of the PDF document

  PDFParser parser = new PDFParser(fileToParse);
  parser.parse();

  //getPDDocument() -- This will get the PD document that was parsed. When you are done with this document you must call    close() on it to release resources
  //PDFTextStripper() -- This class will take a pdf document and strip out all of the text and ignore the formatting and           such.

  String output=new PDFTextStripper().getText(parser.getPDDocument());
  System.out.println(output);
  parser.getPDDocument().close(); 
  driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
  }

}
Here is the output of above program :
EarthBox a Day Giveaway 
Objectives 
EarthBox wanted to engage their Facebook 
audience with an Earth Day promotion that would 
also increase their Facebook likes. They needed a 
simple solution that would allow them to create a 
sweepstakes application themselves. 
 
 
Solution 
EarthBox utilized the Votigo 
platform to create a like-
gated sweepstakes. Utilizing a 
theme and uploading a custom graphic they 
were able to create a branded promotion. 
 
 
Details 
• 1 prize awarded each day for the entire Month of April  
• A grand prize given away on Earth Day  
• Daily winner announcements on Facebook 
• Promoted through email newsletter blast  
 
Results (4 weeks) 
• 6,550 entries 
 
Facebook  

Monday, May 28

Getting google search auto suggestions using Webdriver(Selenium 2)

In the google search when we start typing any search query google will start auto suggestions. All these search suggestions are part of a WebTable. If we would like to capture all these search suggestions then we have to just iterate through the table.

Here is the sample code which will start typing "vam" and then capture all search suggestions .
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class SearchSuggestion {
 
WebDriver driver;
 
 @BeforeTest
 public void start(){
   driver = new FirefoxDriver(); 
 }
  
 @Test
  public void SearchSuggestion() {
  
  driver.get("http://google.com");
  driver.findElement(By.id("gbqfq")).sendKeys("vam");
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  
   WebElement table = driver.findElement(By.className("gssb_m")); 
   List rows = table.findElements(By.tagName("tr")); 
   Iterator i = rows.iterator(); 
   System.out.println("-----------------------------------------"); 
   while(i.hasNext()) { 
           WebElement row = i.next(); 
           List columns = row.findElements(By.tagName("td")); 
           Iterator j = columns.iterator(); 
           while(j.hasNext()) { 
                   WebElement column = j.next(); 
                   System.out.println(column.getText()); 
           } 
           System.out.println(""); 
            
   System.out.println("-----------------------------------------"); 
   } 
  } 
}

Here is what we will see in the browser after running the above code.




Friday, May 25

Selenium WebDriver : getSize() Vs getLocation() functions

Here are the difference between getSize() and getLocation() methods :

getSize() : 
  1. It will returns the "Dimension" object.
  2. If you want to get the width and Height of the specific element on the webpage then use "getsize()" method.
Sample code to get the width and height :
WebDriver driver = new FirefoxDriver(); 
driver.get("https://google.com");
Dimension dimesions=driver.findElement(By.id("gbqfsa")).getSize();
System.out.println("Width : "+dimesions.width);
System.out.println("Height : "+dimesions.height);
Note:
Makesure to import "org.openqa.selenium.Dimension;" package.

getLocation() :
  1. It will return the "Point" object.
  2. If you want to get the exact "x" and "y" coordinates of the element then use "getLocation()"  method.

Sample code to get the "x" and "y" coordinates :
WebDriver driver = new FirefoxDriver(); 
driver.get("https://google.com");
Point point=driver.findElement(By.id("gbqfsa")).getLocation();
System.out.println("X Position : "point.x);
System.out.println("Y Position : "point.y);
Note:
Makesure to import "org.openqa.selenium.Point;" package.

Wednesday, May 23

Starting Opera Browser and Internet Explorer (IE) using WebDriver(Selenium2) with example


In the previous Post we have discussed how to Open Chrome Browser using WebDriver.

Now it is time for Opera :)

Opera and IE browers are as easy as you work with Firefox Browser.

Opera Browser :

Use the below code to start Opera Browser:
DesiredCapabilities capabilities = DesiredCapabilities.opera();
capabilities.setCapability("opera.binary","Absolute Path of Opera browser"); 
//Path will be something like
//C:\Users\\AppData\Local\Programs\Opera\opera.exe 
driver = new OperaDriver(capabilities);
Here is the sample code using TestNG framework
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.opera.core.systems.OperaDriver;

public class opera {
 
 WebDriver driver;
 
 @BeforeTest
 public void open(){ 
  DesiredCapabilities capabilities = DesiredCapabilities.opera();
  capabilities.setCapability("opera.binary", " Absolute Path of Opera browser ");
  driver = new OperaDriver(capabilities); 
 }
 
 @Test
 public void startit(){
  driver.get("http://google.com/");  
 }
 
}

Internet Explorer:

First download  IEDriverServer.exe file from here and save it on your local disk.

Now use the below code to start Internet Explorer 
System.setProperty("webdriver.ie.driver", "Path to IEDriverServer.exe");
driver = new InternetExplorerDriver();
Here is the sample code using TestNG framework.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class IeBrowser {
 
 WebDriver driver;

 @BeforeTest
 public void start(){
   System.setProperty("webdriver.ie.driver", "Path to IEDriverServer.exe");
   driver = new InternetExplorerDriver();
 }
 
 @Test
 public void startit(){
  driver.get("http://google.com");
  
 }

}

Note :
Even if you are using 64-bit operating system try to use 32 bit version of IEDriver as there are some known issues with the 64-bit version of IEDriver.  Especially 64 bit driver is too slow .

https://code.google.com/p/selenium/issues/detail?id=5116#makechanges
https://code.google.com/p/selenium/issues/detail?id=3072

Sunday, May 20

Handling Security Certificates in Firefox using WebDriver

In the Previous Post we have discussed how to handle Security Certificates in IE using WebDriver.

Now it is time for Firefox :)

Handling SSL issues in firefox are easy too. This can be done easily by setting
setAcceptUntrustedCertificates=true

Here is the sample code using TestNG framework :
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public void SecurityAlerts(){

WebDriver driver;

@BeforeTest
public void setUpDriver() {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("setAcceptUntrustedCertificates","true");
driver = new FirefoxDriver(profile);
         }

@Test
public void Start(){
driver.get(URL);
         }
 }



Friday, May 18

Changing the User Language Locale using WebDriver (Selenium2)


Most of the time Websites use the User "Default Language Settings" to display the website look and feel.

If we want to check whether our application is properly internationalized , then we will manually change the language preferences in the browser itself.

But if we want to check the same using webDriver then we have programatically change the user language preferences. And it's simple :)

If you are using Firefox then you can change the Language preferences by the below code

intl.accept_languages= "Language Code"

Here is the sample code using TestNG framework.
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.WebDriver;

public void UserLocale(){

WebDriver  driver;

@BeforeTest
public void setUpDriver() {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("intl.accept_languages","sl");   
driver = new FirefoxDriver(profile);
}

@Test
public void start(){
driver.get("http://google.com");
}

}
If you run the above code then google will be opened in Sloveninan Language and here is the output .. !! :)

Google.com in Sloveninan Language

Tuesday, May 15

Permission denied for to get property Window.frameElement Command duration or timeout: 12 milliseconds

I used to get the below error when I try to switch to iframe ( driver.switchTo().frame("iframe_canvas") ).


Permission denied for <https://apps.facebook.com> to get property Window.frameElement Command duration or timeout: 12 milliseconds Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:09:00' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_23' Driver info: driver.version: RemoteWebDriver
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
at java.lang.reflect.Constructor.newInstance(Unknown Source)


Seems this issue is happening because of Cross Origin .
Solution to this problem is set the below settings in Firefox Profile.
capability.policy.default.Window.QueryInterface='allAccess'

capability.policy.default.Window.frameElement.get='allAccess'

I changed my code as below. Now it is working fine :)
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
 
public void IframeTest(){

 WebDriver driver;

@BeforeTest
  public void setUpDriver() {
   FirefoxProfile profile = new FirefoxProfile();
   profile.setPreference("capability.policy.default.Window.QueryInterface", "allAccess");
   profile.setPreference("capability.policy.default.Window.frameElement.get","allAccess");
   driver = new FirefoxDriver(profile);
     }

@Test
 public void delete(){
   Common.FBLogin(fbUsername, fbPassword, driver);
   driver.get("appURL");
   driver.switchTo().defaultContent();
   driver.switchTo().frame("iframe_canvas");  
  }

}
For more details check this one  :
http://code.google.com/p/selenium/issues/detail?id=2863


If you ever happened to get the above error then change your Firefox preferences from code :)


Friday, May 11

Handling Security Cerificates(UntrustedSSLCertificates) in Internet Explorer (IE) using WebDriver(selenium2)

In automating web based application we will find problem with Security Cerificates(UntrustedSSLCertificates).

And here is a simple solution for this.Just use the below code to cross the SSL page :)

driver.navigate().to("javascript:document.getElementById('overridelink').click()");


If you are using TestNG framework then here is the sample code :

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class SecurityCerts {

 WebDriver  driver;

 @BeforeTest
 public void setUpDriver(){ 
   driver = new InternetExplorerDriver();
    }

 @Test
 public void start(){
 driver.get("https://www.hs.facebook.com/help/community/question/?id=648015478541882");  
 driver.navigate().to("javascript:document.getElementById('overridelink').click()"); 
 }

}


Thursday, May 10

Starting Chrome Browser using WebDriver(Selenium2) with example


If we would like to run our scripts on Chrome we need "chromedriver"along with the actual Chrome Browser.If you try to start the Chrome Browser with the below statement alone
WebDriver driver = new ChromeDriver();

Then you will notice below error statements

"You need to have both chromedriver and a version of chrome browser installed
@BeforeTest setUpDriver
java.lang.IllegalStateException: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
at com.google.common.base.Preconditions.checkState(Preconditions.java:172)
atorg.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:114)"

In our scripts if we dont specify where is chromedriver is located then we cant start chrome browser using WebDriver.

Here are steps to setup chromedriver

1.Download chromedriver from
http://code.google.com/p/chromedriver/downloads/list
2.Unzip the file .Say you downloaded it on your desktop folder named "Automation" and unzipped it then location will be like
C:\\Users\\<<User Name>>\\Desktop\\Automation\chromedriver_win_19.0.1068.0\\chromedriver.exe
3.Use the below code to start chrome
System.setProperty("webdriver.chrome.driver","C:\\Users\\<<UserName>>\\Desktop\\Automation\\chromedriver_win_19.0.1068.0\\chromedriver.exe"); 
ChromeDriver driver = new ChromeDriver();

Now you are done. :)

If you are using the TestNG framework then here is the sample code :

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class chromeDriver {
 
WebDriver  driver;

@BeforeTest
 public void setUpDriver(){
   System.setProperty("webdriver.chrome.driver",
"C:\\Users\\<>\\Desktop\\Automation\\chromedriver_win_19.0.1068.0\\chromedriver.exe");  
   driver = new ChromeDriver(); 
     }

 @Test
 public void start(){
 driver.get("http://www.google.com/"); 
   }

}


TestNG XMLfile preparation and error messages


Here is the sample TestNG file :

  
  
   
               
        
     
   
   
           
        
     
   


It is also important to know about error messages.Sometimes we learn more from errors :)
I have put some of the error messages we get when we go wrong in the above TestNG XML file .

Here are the error codes we will see when we have done any error in the above XML file.

1.If two tests are having the same name then we see below error
Ex :  
<test name="Testing the Google"> 
        <classes>       
        <class name="com.google.UI"/>
     </classes>
  </test> 
  <test name=" Testing the Google "> 
    <classes>       
        <class name="com.google.gmail"/>
     </classes>
  </test> 
Two tests in the same suite cannot have the same name: <<Test anme>>
at org.testng.TestNG.checkTestNames(TestNG.java:981)
at org.testng.TestNG.sanityCheck(TestNG.java:970)
at org.testng.TestNG.run(TestNG.java:1002)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)

2.If the testname doesnot elclosed in double quotes("") then we wills ee below error
Ex :  <test name=Testing the Google> 
The value of attribute "name" associated with an element type "null" must not contain the '<' character.
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:335)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.xml.sax.SAXParseException: The value of attribute "name" associated with an element type "null" must not contain the '<' character.
atcom.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

3.If the class name doesnt end with "/" character then we will see below error
org.testng.TestNGException: org.xml.sax.SAXParseException: The end-tag for element type "class" must end with a '>' delimiter.
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:335)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.xml.sax.SAXParseException: The end-tag for element type "class" must end with a '>' delimiter.

4. If there is no space between parameter name and value  fields then we will see below error 
Ex   :  <parameter name="googleURL"value="http://google.com"/>
org.testng.TestNGException: org.xml.sax.SAXParseException: Element type "parameter" must be followed by either attribute specifications, ">" or "/>".
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:335)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.xml.sax.SAXParseException: Element type "parameter" must be followed by either attribute specifications, ">" or "/>".

5.If the parameter attribute doesnt end with "/" character then we will see below error
Ex   :  <parameter name="googleURL"value="http://google.com">
org.testng.TestNGException: org.xml.sax.SAXParseException: Element type "class" must be followed by either attribute specifications, ">" or "/>".
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:335)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.xml.sax.SAXParseException: Element type "class" must be followed by either attribute specifications, ">" or "/>".


6. If the two parameters have the same name and value attributes then we will see below error
Ex   :  <parameter name="googleURL"value="http://google.com"/>
          <parameter name="googleURL"value="http://google.com"/>
org.testng.TestNGException: org.xml.sax.SAXParseException: Element type "class" must be followed by either attribute specifications, ">" or "/>".
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:335)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.xml.sax.SAXParseException: Element type "class" must be followed by either attribute specifications, ">" or "/>".

7.Make sure there are no spaces between "/" and  ">".If there are any spaces then we will see below error.
Ex   :  <parameter name="googleURL"value="http://google.com"/                >
org.testng.TestNGException: org.xml.sax.SAXParseException: Element type "class" must be followed by either attribute specifications, ">" or "/>".
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:335)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.xml.sax.SAXParseException: Element type "class" must be followed by either attribute specifications, ">" or "/>".

Wednesday, May 9

Getting total no.of Checkboxes/Textboxes/Dropdowns/iframes/Links on a web page



In one of the Previous Post we had details about WebDriver findElements() method. This is very useful to find the total no.of  desired elements on a wepage .

Here are some of the examples :

Getting total no.of Links on a Webpage :
Here is the sample code to get the total no.of links on facebook registration page:
driver.get("http://facebook.com");
List  totalLinks=driver.findElements(By.tagName("a"));
System.out.println("total links "+totalLinks.size());

Getting total no.of checkboxes on a Webpage :
Here is the sample code to get the total no.of checkboxes on facebook registration page:
driver.get("http://facebook.com");
List checkboxes=driver.findElements(By.xpath("//input[@type='checkbox']"));
System.out.println("total checkboes "+checkboxes.size());



Getting total no.of dropdown menus on a Webpage :
Here is the sample code to get the total no.of dropdown menus on a facebook registration page:
driver.get("http://facebook.com");
List dropdown=driver.findElements(By.tagName("select"));
System.out.println("total dropdown lists "+dropdown.size());



Getting total no.of textboxes on a Webpage :
Here is the sample code to get the total no.of textboxes on facebook registration page:
driver.get("http://facebook.com");
List  textboxes=driver.findElements(By.xpath("//input[@type='text'[@class='inputtext']"));
System.out.println("total textboxes "+textboxes.size());

Here is the sample code to get the total no.of textboxes on hotmail registration page:
driver.get("https://signup.live.com");
List  totalTextboxes=driver.findElements(By.xpath("//input[@type='text']"));
System.out.println("total textboxes "totalTextboxes.size());

Getting total no.of iframes on a Webpage :
Here is the sample code to get the total no.of iframes :
driver.get("https://www.facebook.com/googlechrome/app_158587972131");
List  totaliFrames=driver.findElements(By.tagName("iframe"));
System.out.println("total links "+totaliFrames.size());



Monday, May 7

Missing requirement: Jetty Server Adaptor Plug-in 1.0.4 (org.mortbay.jetty.serveradaptor 1.0.4) requires 'bundle org.eclipse.wst.server.core 0.0.0' but it could not be found


Today I tried to install Jetty plugin in Eclipse using the below URL
http://www.webtide.com/eclipse

But my installation failed with the below error

"Cannot complete the install because one or more required items could not be found.
Software currently installed: Jetty Generic Server Adaptor 1.0.
(org.mortbay.jetty.serveradaptor.feature.group 1.0.4)
Missing requirement: Jetty Server Adaptor Plug-in 1.0.4 
(org.mortbay.jetty.serveradaptor 1.0.4) requires 'bundle org.eclipse.wst.server.core 
0.0.0' but it could not be found
Cannot satisfy dependency:
From: Jetty Generic Server Adaptor 1.0.4 
(org.mortbay.jetty.serveradaptor.feature.group 1.0.4)
To: org.mortbay.jetty.serveradaptor [1.0.4] "

Solution to this problem is very simple .

Install Jetty plugin with the below URL
http://download.eclipse.org/jetty/updates/jetty-wtp

Steps :

  1. Open Eclipse.
  2. click Help -> Install New Software. The Available Software dialog box opens.
  3. Add the plugin using below URl  http://download.eclipse.org/jetty/updates/jetty-wtp


Detailed steps with instructions can be found at :
http://wiki.eclipse.org/Jetty_WTP_Plugin/Jetty_WTP_Install

Saturday, May 5

RCT (Root Canal Therapy) - First Appointment with less Pain


Monday -April 30,2012 :
I had severe tooth pain so I left office early for checkup.After going through the initial checkup and X-ray , doctor suggested me to go through RCT ( Root Canal Therapy ) as one of my right tooth decayed and the process will be finished in two appointments. I got my first appointment with surgeon on Friday at 7.30PM ( May 04, 2012).


Friday - May 04, 2012 :
I couldnt make it on friday so I got my treatment to be postponed to Saturday at 6.00PM ( May 05, 2012 ).


Saturday - May 05, 2012 at 6.00 PM :

I was in Hospital.I was very sick and afraid of pain. I am still so much depend on my parents especially when I am sick :P.

I wish my parents could be just beside me so that I can hold their hands when I felt pain.Luckily Dentist friendly smile comfort me little bit.But I know he can never never replace my parents.This Process includes  three steps.



First step is giving anesthetic injection very near to my right decayed tooth which makes of half of my right face numb.

Now the second step is cleaning the tooth which is of no pian :)

And  third step is removing the nerve which is little painy. Dentist told me to raise my hand whenever I felt Pain. In the middle of the process I raised my handas  it is little paining so he stopped for sometime and then started again. Seriously I myself didn't realize what is really happening .The only one thing I know at that time was dentise was just doing something in my mouth and playing with my tooth :)

Entire process was done with in 20 mins.Dentist told me that "my right cheeck will be heavy for another one hour as I have been given anesthetic injection  and he suggested me not to take anything for another one hour".

I was told I can eat whatever I want including chocolates and Icecreams except too much hot and sticky food  :P

And my next treatment will be on Tuesday at 6.30 PM ( May 08,2012) that process will take around 45 mins.

And overall what I can say is "RCT is not painful ". There will be very very very less pain.

Waiting for my next appointment on Tuesday at 6.30 PM ( May 08,2012) :)

Selenium WebDriver : findElement() Vs findElements() functions



It is very important to know the difference between findElement() and findElements() functions and here you go for it :

findElement() :

  1. Find the first element within the current page using the given "locating mechanism".
  2. Returns a single WebElement.
  3. Syntax: WebElement findElement(By by)

Ex:
driver.get("https://signup.live.com");
WebElement firstName=driver.findElement(By.id("iFirstName"));
firstName.sendKeys("Automated First Name");



findElements() :

  1. Find all elements within the current page using the given "locating mechanism".
  2. Returns List of WebElements.
  3. Syntax:  java.util.List<WebElement> findElements(By by)

Ex:
driver.get("https://signup.live.com");
List  textboxes1=driver.findElements(By.xpath("//input[@type='text']"));
System.out.println("total textboxes "+textboxes1.size());

Tuesday, May 1

TestNG : The reference to entity "tab" must end with the ';' delimiter.


Today I have faced problem while running the below TestNg XML file .

<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="testing test suite">
  <parameter name="googlePlayUrl" value="https://play.google.com/store?hl=en&tab=w8"/>
  <test name="checking the Google play">
    <classes>
       <class name="com.google.play.UrlVerification"/>
    </classes>
  </test>
</suite>

When I run the above TestNG XML file I got bellow error

org.testng.TestNGException: org.xml.sax.SAXParseException: The reference to entity "tab" must end with the ';' delimiter.
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:335)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.xml.sax.SAXParseException: The reference to entity "tab" must end with the ';' delimiter.

Solution to the above problem is very simple. Replace the "&" symbol with "&amp;"

I have changed my XML file like below and it was successed.

<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="testing test suite">
  <parameter name="googlePlayUrl" value="https://play.google.com/store?hl=en&amp;tab=w8"/>
  <test name="checking the Google play">
    <classes>
       <class name="com.google.play.UrlVerification"/>
    </classes>
  </test>
</suite>