Behat 2.5 with Drupal 7 - Restart scenario execution when step fails - drupal-7

I have a case when a test step in a scenario fails with a spin timeout. This happens randomly as the next time this scenario runs, the case passes. So I wrote a #AfterStep handleSpinErrors(StepEvent $event) custom function in FeatureContext that checks if the step fails because of a spin timeout. I am able to get the conditions right, but I am not sure how to execute the scenario again from within this function.

What about using the behat build-in --rerun feature? http://docs.behat.org/en/v2.5/guides/6.cli.html

Related

Test Case execution for infinite time using testng

I want to execute some test cases in my selenium framework for infinite time means it should run 24*7. I have tried to search a lot in google but unable to find the solution for it. please help me as how can i achieve this execution using TestNG.
If you want it through testng then what #mackowski suggested should also work - though reports will get overwritten. If you want long running tests and not necessarily all the time tests, then you can put invocationCount as a high number too.
However, I think you should be taking help of Jenkins to schedule this job, say every 2 minutes every hour every day of the week -
simple configuration will handle this for you.
Your reports would be saved for each run
A failure in one will not cause the run to be aborted.
Plus you may run out of memory if you do it in one run.
Take your pick.
There are couple ways of doing that. You need to run your tests in infinite loop. The one way of doing this is to write simple Java program that will run your tests over and over again.
Here is example code
public static void main(String[]args ) {
while(true) {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { Run2.class });
testng.addListener(tla);
testng.run();
}
}
Here you can find how to run TestNG programmatically http://testng.org/doc/documentation-main.html#running-testng-programmatically

WebDriverWait timeout waits for the driver implicit timeout instead of the explicit timeout provided

I am using python with Selenium WebDriver to test an angular based web-app.
In the login helper subroutine, on login, I want to check if it was successful before continuing with rest of the tests.
For this , I have the following piece of code:
login_success = WebDriverWait(self.driver,5).until(EC.visibility_of_element_located((By.CLASS_NAME,"hr-landing")))
if login_success:
self.logger.info("Looks like login was successful")
else:
login_errors = self.get_login_errors()
self.logger.debug(login_errors)
The problem I am facing is with the first line in the code. For a successful login, it returns quickly as the class 'hr-landing' is found.
However, for a failed login, that class is not found , and I wish for the Wait to timeout in 5 seconds as specified in my call to WebDriverWait.
However, the call times out only after 30 seconds (which is the implicit wait I have set on my driver)
How can I get around this issue ? I feel there is no point to providing the explicit timeout , because it is still respecting the implicit one.
Thanks a lot !
Moez.
This is the issue generally we face when both implicit and explicit waits are used. On fail get_login_errors() is called so i am expecting it have implicit waits.
To avoid such issues i hope good to use fluent waits which explained here
Thank You,
Murali

JMeter - alternatives to using While Controller with JDBC Request Child?

My environment: JMeter v2.11, Oracle 12, JDK 7
System: 8000 XML submissions / hour, writes to the database, then after some internal processing, status value in DB is updated (indicating the submission/application has been approved). I have some beanshell samplers setup to source values from a csv file to emulate the XML submission and I have JDBC Request to check when the database status attribute has been updated.
The JDBC request is contained within a While Controller at the end of my thread so that my JDBC request executes until the application.status column is updated.
My test runs fine for a single instance (1 loop) but for subsequent loops, the JDBC request is NOT executed. That is, if the loop count is greater than 1, for each subsequent loop, the JDBC request is NOT executed.
My current setup:
Thread Group: No. of Users-->1, Loop Count -->3
-CSV Data Config: Recycle on EOF = TRUE, STOP THREAD ON EOF = FALSE
-Beanshell Samplers: (to create and submit the XML, using csv data)
--While Controller: (${__javaScript("${status_1}" != "6")})
---JDBC Request: select status from application where applicationID = (select max(applicationID) from application); VariableName: status
As I stated above - the thread runs fine for Loop=1, but if Loop>1 is set, then subsequent loops do NOT execute the JDBC request because of it's relationship to the While Controller.
I've tried adding a parent Simple Controller to the While Controller, I've tried using multiple Loop Controllers and setting a parent Loop Controller to the While Controller but nothing I do works, and I just don't know how to proceed.
I have spent 3 days (really! 3 days!) searching the web for a way to get the While Controller included in subsequent loops - I've found only 3 instances of this question ever being asked on forums going back to 2006, but each question was never actually answered.
It even crossed my mind to create 8000 Thread Groups with a loop of 1!!. It would be a nightmare but would in fact get done what I need - but obviously I'd be here til next year setting that up and I suspect JMeter would run out of resource trying to execute all those thread groups.
Can anyone advise as to some alternatives to my approach. I'm starting to believe the While Controller not being included in subsequent loops is expected/standard JMeter functionality.
Perhaps I can use some other controllers to do what I need?
As always, any help, advice, hints, tips are gratefully appreciated.
This is how your test goes:
First loop: status_1 variable is blank, While Controller is being executed
Second loop: status_1 variable value is 6, While Controller is NOT executed as condition is false.
Add a Debug Sampler before your While Controller to see it yourself
The solution is as simple as just adding the next line to one of your Beanshell Samplers:
vars.remove("status_1");
ResponseMessage="variablescleared";
ResponseCode=200;
This line will clear "status_1" value of "6" and your While Controller will be executed on next iteration.

Unable to find element using selenium webdriver

I am executing 1000 tests using selenium webdriver.
for each test case I need to click "ID" element on the webpage.
I used WebElement x = driver.findElement(By.xpath("//*[#id='TEST']").click(); event.
But unfortunately for couple of test scenarios (2 or 3 out of 1000) it is throwing an error saying that "Unable to find an element". for the remaining test cases it is executing as usual.
I tried to use Try & Catch methods & Refresh the page but functionality is working as usual but performance is too slow.
Have you tried using the ExpectedConditions class ( http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html )
Should be enough to just add some wait for the elementToBeClickable before clicking it.
What do you mean by "Try & Catch methods & Refresh methods".
Selenium imitates a web browser itself, thus it is sometimes unstable.
1000 tests takes a lot of time, so make sure your computer doesn't fall asleep and don't disturb it's test process untill it is done.
Some tests will fail if you minimize the browser.
I would recommend possibly increasing your implicit wait. Something like
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

App Engine: Is it possible to enqueue tasks asynchronously?

Many of my handlers add a task to a task queue to do non-critical background processing. Since this processing isn't critical, if the call to taskqueue.add() throws an exception, my code just ignores it.
Tonight the task queue seemed to be down for around half an hour. Although my handlers correctly ignored the failure, they took about 5 seconds for the taskqueue.add() call to timeout and move on to processing the rest of the page. This therefore made my site run very slowly.
So, is it possible to enqueue a task asynchronously - meaning a way to add a task, without waiting to see if the addition succeeded?
Alternatively, is there a way to reduce that timeout from 5 seconds down to eg 1 second?
Thanks.
You can use the new taskqueue methods create_rpc and add_async. If you don't care if the add succeeds, simply call add_async and ignore the result. If you care, but only want to wait 1 second, set the deadline when calling create_rpc, and use the return value as the RPC argument to add_async. Call get_result to find out if the tasks were successfully added.
I think you can't do anything about it because the RPC call underneath the add method is a synchronous blocking API call.
You could try to add some check using the Capabilities API.
I am pretty sure GAE announced that TQ adds will be async with the next release (experimental feature).

Resources