Firebug and FirePath add-ons of Firefox browser are playing major role to get the XPath and CSS path of any element easily and quickly. Earlier we learnt how to use firebug and firepath add-on with Firefox browser to get XPath or CSS of any element In THIS POST. Now supposing I need both
these add-ons In Firefox Driver Instance when I run my test using selenium WebDriver FirefoxDriver Instance. Is It possible? Yes - Let's see how can we do It.As you know, It Is launching Firefox browser Instance with fresh profile every time when you execute selenium WebDriver test. So Firebug and FirePath will be not available In that fresh created profile of WebDriver FirefoxDriver Instance. Bellow given steps will add Firebug and FirePath In WebDriver FirefoxDriver Instance for you.
Download .xpi files of Firebug and FirePath add-on
First of all we need to download .xpi files of Firebug and FirePath add-on and then we will attach both these files with WebDriver FirefoxDriver Instance profile during test execution.
Download latest .xpi file of Firebug
You need Google Chrome or Internet Explorer browser to download .xpi file.
- Open Google Chrome browser.
- In Google Chrome browser, Go to Firebug add-on DOWNLOAD PAGE.
- Click on "Download Now" button on Firebug add-on download page as shown In bellow Image.
- Click on "download anyway" link as shown bellow. It will download .xpi file of firebug.
Download latest .xpi file of Firebug
- Open Chrome browser.
- In Chrome browser, Go to Firepath add-on DOWNLOAD PAGE.
- Click on "Download Now" button and then click on "download anyway" link. firepath's .xpi file will be downloaded.
Current latest version of firebug Is 2.0.10 and firepath Is 0.9.7.1.1 so downloaded file will be "firebug-2.0.10-fx.xpi" and "firepath-0.9.7.1-fx.xpi". Firebug and FirePath versions can be change In future so file name will be different In future based on version.
Put firebug and firepath .xpi files In D: drive.
Create and run WebDriver test with firebug and firepath add-on
Now we can launch FirefoxDriver Instance with firebug and firepath add-on. We will create custom FirefoxDriver profile on run time and then attach both these add-ons with that custom profile. So new launched FirefoxDriver Instance will have firebug and firepath add-ons.
Execute bellow given test In your eclipse and verify firefox driver Instance Is launched with firebug and firepath add-ons or not.
package Testing_Pack;
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class Firebug {
public static void main(String[] args) throws IOException {
// Set Firebug and Firepath xpi file's path.
// Note : both file's name and path should be proper. Please verify It twice.
File firebug_path = new File("D:\\firebug-2.0.10-fx.xpi");
File firepath_path = new File("D:\\firepath-0.9.7.1-fx.xpi");
// Create firefox driver Instance profile.
FirefoxProfile firefoxprofile = new FirefoxProfile();
// Add Firebug add-on to new created profile of Firefox browser.
firefoxprofile.addExtension(firebug_path);
// Add FirePath add-on to new created profile of Firefox browser.
firefoxprofile.addExtension(firepath_path);
// Pass new created Firefox profile to the FirefoxDriver instance.
WebDriver driver = new FirefoxDriver(firefoxprofile);
driver.get("http://only-testing-blog.blogspot.in/2014/04/calc.html");
}
}
When I run above test, my firefox driver Instance Is launched with firebug and firepath add-ons as shown In bellow Image.
This way you can use firebug and fire path add-on run time to get XPath of any element when you run your tests. THIS POST will show you how to get xpath or CSS path using firebug and firepath.
No comments:
Post a Comment