Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
prasad ginjupalli
Posts : 2
Join date : 2015-05-22

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Fri May 22, 2015 2:03 pm
Hi everyone,
We have recently started automating the Test Cases of our websites using Selenium Webdriver.
However we find that even though a test case has been correctly automated, it cannot be executed in a  reliable fashion:
-    Different parts of a website get loaded at different speeds (due to various factors like net traffic, server load etc.)
-    If the web-control (text box, frame etc..) has not yet loaded in the browser when Selenium starts to look for it, the script will simply fail with a message that the control was not found.
-    The solutions we have found so far on the internet is that we should increase the time that Selenium should wait till it starts looking for the control.
-    The trouble is that each time it seems to fail at a different point or control on the website.
-    This forces us to introduce a “thread.sleep()” statement at each and every step i.e. before  each click, text entry, item selection etc.
-    This however has the downside of hugely increasing the test execution time.

Any advice from you on this would be much appreciated.
avatar
Job46
Posts : 3
Join date : 2015-05-22

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty Re: How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Fri May 22, 2015 4:23 pm
Hello,
you can change the command 'click' by using 'clickAndWait' in the Selenium IDE.

Or you cant try "SeleniumUtils.WaitForElement(By./* you put your web control */, driver);

Ex: (C# code)

SeleniumUtils.WaitForElement(By.LinkText("test"), driver);

driver.FindElement(By.LinkText("test")).Click();
avatar
prasad ginjupalli
Posts : 2
Join date : 2015-05-22

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty Re: How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Tue May 26, 2015 12:03 pm
Hi Job46,

Thank you for your advice.

we will try this and let you know results
avatar
AgoBalan
Amateur
Amateur
Posts : 36
Join date : 2015-02-23

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty Re: How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Fri May 29, 2015 1:56 pm
Dear Job46,
please be careful wilreplying back to users,in your reply "SeleniumUtils.WaitForElement(By.LinkText("test"), driver);" 
is SeleniumUtils a method in  selenium or a class in your framework?,I think its a class in your framewrok there is no SeleniumUtils method in selenium,

New user will get confused so easily,they might look for SeleniumUtils method in selenium jar file
avatar
AgoBalan
Amateur
Amateur
Posts : 36
Join date : 2015-02-23

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty Re: How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Fri May 29, 2015 2:02 pm
dear prasad ginjupalli,
Always define your own  method  for all raw selenium command,for example insteasd of directlky using driver.click method,you should have your own defined method for click,

public void clickOnWEbElements(String strXpath){
int iMaximumTimeWait=30;
while(!iMaximumTimeWait=0){
  try{
  driver.findelement(By.xpath("passed xpath value")).click();
   break;
   }
  catch(Exception e){
  Thread.sleep(1000);
  iMaximumTimeWait=iMaximumTimeWait-1;
  }
}
if(iMaximumTimeWait==0){
"break execution";
}
}
avatar
Job46
Posts : 3
Join date : 2015-05-22

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty Re: How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Fri May 29, 2015 5:15 pm
hey ! 
I finally tried something new using @AgoBalans code.
This is my version:

public void clickOnWEbElementsCAR(String strXpath)
        {
            countDown(By.XPath(strXpath));
        }


public void countDown(By by)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            while (stopwatch.ElapsedMilliseconds < 60000) // 1 min before timeOut
            {
                try
                {
                    driver.FindElement(by).Click();
                    break;
                }
                catch (Exception)
                {
                    // Ignore errors if unable to click
                }

            }
        }
avatar
AgoBalan
Amateur
Amateur
Posts : 36
Join date : 2015-02-23

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty Re: How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Fri May 29, 2015 5:18 pm
Very Happy
Sponsored content

How to minimize test cases execution time Vs timeout failures  in Selenium WebDriver Empty Re: How to minimize test cases execution time Vs timeout failures in Selenium WebDriver

Back to top
Permissions in this forum:
You cannot reply to topics in this forum