Is there any way in calabash- android to run a single step in a scenario for multiple times - calabash-android

I want to run a single step in the my scenarios for multiple times. My scenario consists of connect and disconnect steps.
I have used the while loop to do a work around for it,but was helpless, as the test fails with 'Ambiguous match of "I tap on disconnect button":'. This may be reason as the test executes the same line "I tap on disconnect button" or "I tap on connect" multiple,which Gerkhin may not support as the language is repeating while the loop is running.
Here are the steps:
Then I select the item from the list
Then I tap on disconnect button
Then I tap on connect to reconnect
I want second two steps to be executes 10 times when the run the scenarios.
Can someone help on this.

You can make it like this
Then I restart connection
step def:
$i = 0
$num = 10
while $i < $num do
#YOUR CODE HERE
#DISCONNECT
sleep(3)
#CONNECT
puts("Inside the loop i = #$i" )
$i +=1
end
It should work if you use only one element of UI and you dont change it, on the other hand to help you in future if you have problem with multiply different elements in calabash-android use Table calabash-android construction.

Could you not just make the step definition
Then I reconnect 5 times
Step def
Then /^I reconnect (.*) times$/ do |repetitions|
repetition.times do
... your code here
end
end

Related

set sleep after the execution of every single keyword in Robot Framework

I have several UI test cases where the code looks like
Click …
Sleep 1
Click …
Sleep 1
.
.
etc
I want reduce the redundancy of code so that I write only the keywords and it automatically sleep one second after the execution of each, is there a way in RObotFramework?
You can set a delay for every test step you have by using "Set Selenium Speed"
Then you don't need to put sleep after every test step.
http://robotframework.org/Selenium2Library/Selenium2Library.html#Set%20Selenium%20Speed

Unable to switch to frame in loop in selenium

`I am trying to switch to particular frame using selenium python in loop. It gets executed the first time but after that gives timeout exception error. Here is the code:
Navigate.py:
def navigate_to_frame():
driver.switch_to.default_content()
//Navigation to the frame using execute script
action.py
def perform():
driver.switch_to.default_content()
driver.switch_to.frame(frame)
//Perform required actions
Start.py
for i in range(0,5):
navigate_to_frame()
perform()
The above code works for first time but in the second iteration it throws an exception
I found the solution somewhere else. Came back to answer it.
You are still in the first frame from your first iteration when you try to select from the second iteration.
You need to leave the frame it at the end of the first loop to reset where you are looking at. For example with. a "select frame relative=top".

GML Alarm event not working second time

I have my game setup so that it starts and goes back to a loading screen room for 45 steps after which the next room is randomized. So at alarm[0] the following code activates:
randomize();
chosenRoom = choose(rm_roomOne, rm_roomTwo, rm_roomThree, rm_roomFour);
room_goto(chosenRoom);
The code here works fine the first time, but when it goes back from the randomly chosen room to the loading screen room it stays there and doesn't execute the code again.
Any help would be very much appreciated.
This may sound stupid but did you remember to set the alarm again after it's gone off? I know I've done this several times without thinking. Without seeing your code, I assume that after the alarm goes off it's not being set again, so it won't go off again.
I'm guessing the control object is "persistant", thus the Control Object only exists once and will remain forever (also after swithcing rooms) - thus thie create event only gets fired once - thus the alarm only gets set once.
Try to move your code to the event "Room Start" in your controller and it will work.
you can use event_perform(ev_alarm,0);.
The code here performs alarm[0] after 45 steps. after 45 steps again it triggers alarm[0]. Note that you have to put it in step event. And you have to initialize wait variable and times to zero in create event.
times is the repeat and wait is distance between events.
if(wait == 45 && times !=2){
event_perform(ev_alarm,0);
times++;
wait = 0;
}
else{
wait++;
}

cocoa-applescript: running handler or command every few seconds

In normal applescript, the script is executed down the page, and so any code in loops for every 5 seconds will only run while the loop is running - there is no way to have a single function run every few second regardless of what the script is currently doing or where it is in the script (that I know of). In cocoa-applescript, however, is there a way to run a handler every 5 seconds, at all times, no matter what it is currently doing? Here is what it should be doing in my cocoa-applescript app:
on checkInternetStrength()
do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep 'agrCtlRSSI:'" -- this being the script which returns the line containing the signal strength
set SignalStrength to result
set RSSIcount to (count of characters in SignalStrength)
set SignalStrength to ((characters 18 thru RSSIcount of SignalStrength) as string) as integer -- this to turn SignalStrength into just the number and not the whole output line
set SignalStrength to (100 + SignalStrength) as integer
set SignalBar's setIntValue_(SignalStrength) -- SignalBar being the Level Indicator described below
end checkInternetStrength
Summed up, it runs the airport command to check internet connection, turns this into a number from 1 to 100 and uses this on an NSLevelIndicator (100 maximum) to show current signal strength graphically. Now, there is no point having this run once or when you hit a button - that is an option, but it would be nice if it updated itself every, say, 5 seconds with the realtime value. So is there any way to have a process which runs every 5 seconds to do this, while still enabling full functionality of the rest of the script and interface - i.e. as a background process? Comment if you need more extracts from the script.
Example
In Unity-C# scripting, the 'void Update() {code}' will run the code within it every frame while doing everything else simultaneously, so a cocoa-applescript version of this might be an answer, if anyone knows.
I Dont believe this is possible but what I had a similar problem before, what i do, I have an external applescript applicaion that is hidden the repeats the commands, the only problem is, it wont send it back to the app, you'll have to make the external applescript app do it, like
display notification, etc..., in the applescript apps "Info.plist" you can add this:
<key>LSUIElement</key>
<string>1</string>
To make the app run invisibly, but sorry i dont think you can run a handler in the app its self

jmeter stop current iteration

I am facing the following problem:
I have multiple HTTP Requests in my testplan.
I want every request to be repeated 4 times if they fail.
I realized that with a BeanShell Assertion, and its already working fine.
My problem is, that I don't want requests to be executed if a previous Request failed 5 times,
BUT I also dont want the thread to end.
I just want the current thread iteration to end,
so that the next iteration of the thread can start again with the 1st request (if the thread is meant to be repeated).
How do I realize that within the BeanShell Assertion?
Here is just a short extract of my code where i want the solution to have
badResponseCounter is being increased for every failed try of the request, this seems to work so far. Afterwards, the variable gets resetted.
if (badResponseCounter = 5) {
badResponseCounter = 0;
// Stop current iteration
}
I already checked the API, methods like setStopTest() or setStopThread() are given, but nothing for quitting the current iteration. I also need the preference "continue" in the thread group, as otherwise the entire test will stop after 1 single request failed.
Any ideas of how to do this?
In my opinion the easiest way is using following combination:
If Controller to check ${JMeterThread.last_sample_ok} and badResponseCounter variables
Test Action Sampler as a child of If Controller configured to "Go to next loop iteration"
Try this.
ctx.setRestartNextLoop(true);
if the thread number is 2, i tried to skip. I get the below result as i expected (it does not call b-2). It does not kill the thread either.