Powered By Blogger

Search Here!

Friday, September 28, 2012

SpecFlow Error : Step bindings are still being analyzed. Please wait. !


I am having problems generating the step definitions. I'm using Visual Studio 2010 Professional fully patched.

My scenario tests do work, everything is "green". But when I want to navigate from a feature step to its binded method I get the error "Step bindings are still being analyzed. Please wait."


Solution: Clean the solution and then rebuild, it solved.

SpecFlow: Step Intellisense in VisualStudio !


SpecFlow is aiming at providing pragmatic BDD for .NET.

SpecFlow 1.5 comes with Intellisense for step-completion in VisualStudio 2010:



When you are writing feature files, you get Intellisense after Given/When/Then/And/But keywords.
As usual you can trigger Intellisense with Ctrl-Space.

The feature is switched off by default. You have to enable it under Menu –> Tools –> Options then choose SpecFlow. In the Editor Settings set 'Enable Intellisense' to True:



SpecFlow can be downloaded from GitHub.

Keep your SpecFlow flowing :)

Friday, September 14, 2012

WebDriver Handling Environment Slowness !

Best way to handle WebDriver code in the environment slowness. We have faced too many issues due to slow environment for our website, in night when usage gone down then WebDriver working perfectly but generally in day time when we have large usage then it’s very hectic to handle even for the perfectly written scripts.    

So, I used the pageLoadTimeout method that solves all the problem that we were facing due to environment slowness. I used in the WebDriver instance initiate so for each and every WebDriver command it always check for page load.

public static IWebDriver WebDriver
        {
            get
            {
                if (_webdriver == null)
                    _webdriver = GenericHelper.GetWebDriverInstance();
                _webdriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(2));
                return _webdriver;
            }
        }

You can use other methods also as per your use.

WebDriver.Timeouts
implicitlyWait(long time, java.util.concurrent.TimeUnit unit)
Specifies the amount of time the driver should wait when searching for an element if it is not immediately present.
WebDriver.Timeouts
pageLoadTimeout(long time, java.util.concurrent.TimeUnit unit)
Sets the amount of time to wait for a page load to complete before throwing an error.
WebDriver.Timeouts
setScriptTimeout(long time, java.util.concurrent.TimeUnit unit)
Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error.

Sunday, September 2, 2012

WebDriver: Click Techniques !


There are number of techniques by which you can interact with web page. As Selenium tool - WebDriver is a very strong tool to interact with various elements on web page but sometimes we stuck in this and not able to understand why it is happening. If we are doing Automation it means, it would work in every condition and every environment. From my experience once time, my code is able to click an element on my local system but same code when running on taking system remote, it won't(we had the same environment on both the systems).

So, I mean there is a lack of interaction of WebDriver with web page when I was running it on remote system yes there was some network speed issue but we already used the ideal waits for elements.

I came to know that there were lots of JavaScript on page where I was generally getting issue due to JavaScript error(s) or due to lazy load of JavaScript on the webpage. Sometimes JavaScript fully loaded on the page sometimes not due to network speed on the remote system. As WebDriver itself is a JavaScript based tool, so could not go beyond that to avoid JavaScript based errors.

So, Following techniques helps you to click element on the page and various other actions too:

If page or pop up’s contains no JavaScript then we can use for click,

WebDriver.FindElement(By.Id("_ctl0_ContentHolderHeader_lbtnSavePrefHeader")).Click();

If page or pop up’s contains some JavaScript’s then we can use for click,

IWebElement isPageLoaded = WebDriver.FindElement(By.Id("ImgPoweredBy"));
isPageLoaded.Click();

If page or pop up’s contains possible more JavaScript and JavaScript’s Errors then we can use for click,

IWebElement menu = WebDriver.FindElement(By.XPath("//table[@id='GridStudent']/tbody/tr/td[2]/span"));
            Actions builder = new Actions(WebDriver);
            builder.Click(menu).Perform();

If page or pop up’s contains highly JavaScript’s and JavaScript’s Errors then we can use,

IWebElement menu = WebDriver.FindElement(By.XPath("//table[@id='GridStudent']/tbody/tr/td[2]/span")); 
((IJavaScriptExecutor)WebDriver).ExecuteScript("$(arguments[0]).click()",menu);