[selenium-users] Use of Firefox Adblock with Selenium

1,739 views
Skip to first unread message

Jonathan

unread,
May 19, 2010, 1:30:20 PM5/19/10
to Selenium Users
When Selenium opens a Firefox browser instance, it doesn' load the add-
ons. I specifically want to use Ad Block (adblock) so as to refrain
from loading 3rd party ads which can speed up my testing + also help
stabilize the tests, as sometimes 3rd party ads simply don't load.

How can I do this?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Niraj Kumar

unread,
May 21, 2010, 4:48:21 AM5/21/10
to seleniu...@googlegroups.com
Since selenium Creates a new and clean profile each time you test case runs so follow this process you will get what you want.

1. First you need to create a firefox profile
 Close all instances of firefox then using run create a new firefox profile  :  type firefox - p
2. Install the add-ons whatever you want.
3. set the selenium setFirefoxProfileTemplate to you new firefox profile.
4. Run the test cases . this will use your newly created firefox that will have adons.

How to set the selenium property to use our own firefox profile


import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.annotations.*;
import com.thoughtworks.selenium.*;
import java.io.File;

public class firefoxprofile extends SeleneseTestCase {
   
    private SeleniumServer seleniumServer;
    private Selenium selenium;
    public static final String MAX_WAIT_TIME_IN_MS="60000";

    @BeforeClass
    public void setUp() throws Exception {
       
        File template = new File("C:\\nk");
        RemoteControlConfiguration rc = new RemoteControlConfiguration();
        rc.setSingleWindow(true);
        rc.setFirefoxProfileTemplate(template);
        seleniumServer = new SeleniumServer(rc);
        selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/");
        seleniumServer.start();
        selenium.start();
             
       }
  

    @Test
    public void googling() {
    selenium.open("/");
    selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
    selenium.type("q", "http://automationtricks.blogspot.com");
    selenium.click("btnG");
    selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
    assertTrue(selenium.isTextPresent("http://automationtricks.blogspot.com"));
}
   
   
    @AfterTest
    public void tearDown() throws InterruptedException{
        selenium.stop();
        seleniumServer.stop();
--
Thanks & Regard,
Niraj Kumar
Reply all
Reply to author
Forward
0 new messages