Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Regarding Alert Interface
Fri Feb 24, 2017 2:00 pm by karthikeyakumar

» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

View previous topic View next topic Go down

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

Post by prasad ginjupalli on 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.

prasad ginjupalli

Posts : 2
Join date : 2015-05-22

Back to top Go down

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

Post by Job46 on 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();

Job46

Posts : 3
Join date : 2015-05-22

Back to top Go down

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

Post by prasad ginjupalli on Tue May 26, 2015 12:03 pm

Hi Job46,

Thank you for your advice.

we will try this and let you know results

prasad ginjupalli

Posts : 2
Join date : 2015-05-22

Back to top Go down

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

Post by AgoBalan on 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

AgoBalan
Amateur
Amateur

Posts : 36
Join date : 2015-02-23

Back to top Go down

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

Post by AgoBalan on 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";
}
}

AgoBalan
Amateur
Amateur

Posts : 36
Join date : 2015-02-23

Back to top Go down

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

Post by Job46 on 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
                }

            }
        }

Job46

Posts : 3
Join date : 2015-05-22

Back to top Go down

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

Post by AgoBalan on Fri May 29, 2015 5:18 pm

Very Happy

AgoBalan
Amateur
Amateur

Posts : 36
Join date : 2015-02-23

Back to top Go down

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

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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