Geetha February 2016

Selenium Firefox Pop-up blocker leads to fail the test case execution

We are using the selenium with firefox webdriver to automate all our test cases.

I'm automating the SDL Tridion manual activities like Creating a Component, Creating a Page, Tridion out-of box search etc....

When I run the test cases for Page Creation test case, Firefox's pop up blocker ending up blocking the window that is supposed to open. This leads to failing the test case, but for other test cases it is working fine(FYI : I'm running it from my local)

On the top of this selenium project we have built one asp.net web application and the application has been configured in the IIS Successfully. When I run this project by hitting the server URL, All the test cases got executed successfully.(Note: No Firefox pop-up blocker issue)
But we couln't execute the selenium project from our local, because of the firefox driver pop-up blocker issue.

I have tried a couple of things but they didn't work out, And those are mentioned here
1. Given the URL of the site in the firefox setting's(Options->Content->Add Exceptions->URL of the Site)
2. Setting the preference in the firefox profile like below

[TestFixtureSetUp]
        public void Init()
        {
            try
            {
                //driver = new FirefoxDriver();
                //FirefoxBinary fb = new FirefoxBinary(@ConfigurationManager.AppSettings["FirefoxBinaryLocation"]);
                FirefoxBinary fb = new FirefoxBinary(@ConfigurationManager.AppSettings["FirefoxBinaryLocation"]);
                FirefoxProfile fp = new FirefoxProfile();
                fp.SetPreference("browser.startup.homepage_override.mstone", "ignore");

                driver = new FirefoxDriver(fb, fp);
            }
            catch (System.Exception ex)
            {
                logger.WriteError("Exception in instantiating Firefox driver : " + ex.Message);                
            }
        }
<

Answers


Arun Prakash February 2016

Popups are handled in Firefox with the key "dom.disable_open_during_load". You can set this key value to false, which will allow popup windows. This key value can be set in desired capabilities.


Geetha February 2016


I found a solution for my post. Actually I was using element.sendKeys(Enter), Actually this won't work out while clicking a button in firefox. So I changed this to JavaScript Executor, I added the below code and it is working fine

IwebElement element = driver.findelement(By.Id("Id name goes here"))
IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;
executor.ExecuteScript("arguments[0].click();",element);

Hope this might helpful to others.

Post Status

Asked in February 2016
Viewed 3,680 times
Voted 11
Answered 2 times

Search




Leave an answer