Steps
1. Close all instances of firefox browser.
2. Create a new firefox profile : Go to Run and type firefox -p and press OK . This will open a dilog bod where you create new firefox profile, have a name "nk" and save it in C: drive.
3. Start the browser: Go to run and type firefox -p that will open a dialog box. Select the profile "NK" which you created in the 2nd step.
4. Install all plug-ins in this profile ; like SSL security bypass
https://addons.mozilla.org/en-US/firefox/addon/10246/
5. Now you write you test cases like below
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();
}
}
My test remembers its cookies and information when I am running tests using *iexplore. How do I start new IE session without remembering old cookies and information?
ReplyDeleteThanks,
Vasavi
I believe selenium starts a new and fresh browser session every time a test runs.
ReplyDeleteBut if you use your profile then all adons will be there to assist you for your testing.
Thanks
Niraj, You have a lot of really good tips here. Thanks for sharing.
ReplyDeleteI tried this one without success however. I created a new profile and set the user_agent. I then launched whatsmyuseragent.com and expected to see the string i enter (which would indicate it found the correct one). It did not work. Have you successfully changed user agent?
My bad Niraj. I got it working. The problem was that I used the name of Profile when I created it rather than the name of the file as Firefox saved it. Many thanks for these tips. Keep them coming.
ReplyDeleteNiraj: I found this post very useful. I appreciate it for sharing this trick. BTW, is there a way to avoid the adons pop-up everytime the profile template is loaded?. I am afraid it might interfere with multi-window actions. Thanks!.
ReplyDeleteThanks Niraj for the helpful tips. Do you have the same instructions for linux?
ReplyDeletemild infections can be vulcanized with this and you lodge to your decision to bring around yeast infection naturally,
ReplyDeleteyou are on the proper way to get rid of it for
a retentive time period of sentence.
my weblog: yeast infection in toddlers
Hi Niraj,
ReplyDeleteI have a problem with Facebook API,while running test script it hits log in with Facebook user button then Facebook API pop up window appears, It enters user id, password and clicked on log in button, i am getting Facebook API pop up White blank and not redirected. I am using selenium RC. Let me know any solution for this please help me.
Thanks& Regards
Satya Ranimekala
Very nicee blog you have here
ReplyDelete