XCUI tests failed due to Asynchronous wait failed: Exceeded timeout of 30 seconds, with unfulfilled expectations - xcode8

let webViewsQuery = app.webViews
let emailOrPhoneTextField = webViewsQuery/*#START_MENU_TOKEN#*/.textFields["Email or phone"]/*[[".otherElements[\"Sign in – Google accounts\"].textFields[\"Email or phone\"]",".textFields[\"Email or phone\"]"],[[[-1,1],[-1,0]]],[0]]#END_MENU_TOKEN#*/
let exists = NSPredicate(format: "exists == TextField")
expectation(for: exists, evaluatedWith: emailOrPhoneTextField, handler: nil)
waitForExpectations(timeout: 30, handler: nil)
emailOrPhoneTextField.tap()
Asynchronous wait failed: Exceeded timeout of 30 seconds, with unfulfilled expectations: "Expect predicate exists == 1 for object "Email or phone" TextField" when running through fastlane scan

That's because you've never fulfilled your expectation (with expectation.fulfill() method). Use XCTWaiter if you don't care about expectation fulfilment.

Is it not just that you need to make your expectation evaluate to true?
let exists = NSPredicate(format: "exists == true")
or
let exists = NSPredicate(format: "exists == 1")

Related

How to make Area2D keep track of body entry all the time?

sorry for my bad english.
I have a problem. I need to make Area2D keep track of body entered all the time but it did it one time. How i can track this?
Code that i tried to use:
var hp = 10
var hero_in_me = false
func _physics_process(delta):
if hero_in_me == true:
hp -= 1
print(hp)
func _on_Area2D_body_entered(body):
if body.name == "Hero":
hero_in_me = true
I'm not sure what you mean by "all the time", given that the "body_entered" signal notifies you when the body entered. So, either you want to know all the time the body is inside, or you want to register when the body exited and entered again.
Either way, you would, of course, need to handle when the body exists the Area2D, so you know when the body is no longer inside.
Assuming the "body_entered" signal is connected to _on_Area2D_body_entered and the "body_exited" signal is connected to _on_Area2D_body_exited, you could do this:
var hero_in_me = false
func _on_Area2D_body_entered(body):
if body.name == "Hero":
hero_in_me = true
func _on_Area2D_body_exited(body):
if body.name == "Hero":
hero_in_me = false
And there you can check for hero_in_me.
Or like this:
var hero = null
func _on_Area2D_body_entered(body):
if hero == null and body.name == "Hero":
hero = body
func _on_Area2D_body_exited(body):
if body == hero
hero = null
And there you can check for hero != null. And you also have the reference if you need to call into it.
Or if you want to keep track of all the bodies that enter the Area2D, you can store them in an array:
var bodies_inside := []
func _on_Area2D_body_entered(body):
bodies_inside.append(body)
func _on_Area2D_body_exited(body):
bodies_inside.erase(body)
Then to check if a particular body is inside, you could check bodies_inside.has(body). You could also loop over the array to access all the bodies.

Receive message from an Elm process

I'm toying around with Elm processes in order to learn more about how they work. In parts of this, I'm trying to implement a timer.
I bumped into an obstacle, however: I can't find a way to access the result of a process' task in the rest of the code.
For a second, I hoped that if I make the task resolve with a Cmd, the Elm runtime would be kind enough to perform that effect for me, but that was a naive idea:
type Msg
= Spawned Process.Id
| TimeIsUp
init _ =
( Nothing
, Task.perform Spawned (Process.spawn backgroundTask)
)
backgroundTask : Task.Task y (Platform.Cmd.Cmd Msg)
backgroundTask =
Process.sleep 1000
-- pathetic attempt to send a Msg starts here
|> Task.map ( always
<| Task.perform (always TimeIsUp)
<| Task.succeed ()
)
-- and ends here
|> Task.map (Debug.log "Timer finished") -- logs "Timer finished: <internals>"
update msg state =
case msg of
Spawned id ->
(Just id, Cmd.none)
TimeIsUp ->
(Nothing, Cmd.none)
view state =
case state of
Just id ->
text "Running"
Nothing ->
text "Time is up"
The docs say
there is no public API for processes to communicate with each other.
I'm not sure if that implies that a process can't cummunicate with the rest of the app.
Is there any way to have update function receive a TimeIsUp once the process exits?
There is one way but it requires a port of hell:
make a fake HTTP request from the process,
then intercept it via JavaScript
and pass it back to Elm.
port ofHell : (() -> msg) -> Sub msg
subscriptions _ =
ofHell (always TimeIsUp)
backgroundTask : Task.Task y (Http.Response String)
backgroundTask =
Process.sleep 1000
-- nasty hack starts here
|> Task.andThen ( always
<| Http.task { method = "EVIL"
, headers = []
, url = ""
, body = Http.emptyBody
, resolver = Http.stringResolver (always Ok "")
, timeout = Nothing
}
)
Under the hood, Http.task invokes new XMLHttpRequest(), so we can intercept it by redefining that constructor.
<script src="elm-app.js"></script>
<div id=hack></div>
<script>
var app = Elm.Hack.init({
node: document.getElementById('hack')
})
var orig = window.XMLHttpRequest
window.XMLHttpRequest = function () {
var req = new orig()
var orig = req.open
req.open = function (method) {
if (method == 'EVIL') {
app.ports.ofHell.send(null)
}
return orig.open.apply(this, arguments)
}
return req
}
</script>
The solution is not production ready, but it does let you continue playing around with Elm processes.
Elm Processes aren't a fully fledged API at the moment. It's not possible to do what you want with the Process library on its own.
See the notes in the docs for Process.spawn:
Note: This creates a relatively restricted kind of Process because it cannot receive any messages. More flexibility for user-defined processes will come in a later release!
and the whole Future Plans section, eg.:
Right now, this library is pretty sparse. For example, there is no public API for processes to communicate with each other.

Is there a way to assert and fail a request after polling in karate?

I have a request where i get Processing or Submitted in a response parameter if the request is in process or passed respectively.
I am able to poll and get if the status is "Processing" or"Submitted" but after that I am unable to fail the request if still i am not getting the expected status after polling for 5 times.
How can i fail request after certain retries do not provide me expected response?
The answer is in your question,
I assume you are polling using a js function,
If so you can add a boolean return from that, if you condition not met return false or if condition met return true then assert the value returned from your feature file.
* def pollingFunc =
"""
function(x) {
// your polling logic which retrives status
if (status == x) {
return true;
}
else{
return false;
}
}
"""
In feature
* def statusFound = pollingFunc("Processed" )
* assert (statusFound == true)
If the expected status not obtained after polling the assert will fail the test

Redis - Reliable queue pattern with multiple pops in one request

I have implemented Redis's reliable queue pattern using BRPOPLPUSH because I want to avoid polling.
However this results in a network request for each item. How can I augment this so that a worker BRPOPLPUSH'es multiple entries at once?
While BRPOPLPUSH is blocking version of RPOPLSPUSH and do not support transactions and you cant handle multiple entries. Also you cant use LUA for this purposes because of LUA execution nature: server would be blocked for new requests before LUA script has finished.
You can use application side logic to resolve queue pattern you need. Pseudo language
func MyBRPOPLPUSH(source, dest, maxItems = 1, timeOutTime = 0) {
items = []
timeOut = time() + timeOutTime
while ((timeOut > 0 && time() < timeOut) || items.count < maxItems) {
item = redis.RPOPLSPUSH(source, dest)
if (item == nil) {
sleep(someTimeHere);
continue;
}
items.add(item)
}

GetOverlappedResult return true,but no data write

I check async write with following code.
BOOL bOk = ::GetOverlappedResult(hFile, pOverlapped, dwBytesTransferred, TRUE);
if ( FALSE == bOk )
{
TRACE_ERROR_NO_ASSERT(GetOverlappedResult);
}
bOk is TRUE, but dwBytesTransferred is 0, and pOverlapped->Internal is 258(timeout).
my questionn is : is my async operation timeout and will be finished later? or just failed? should I call CancelIo to cancel this timeout operation like this?
BOOL bOk = ::GetOverlappedResult(hFile, pOverlapped, dwBytesTransferred, TRUE);
if ( FALSE == bOk )
{
TRACE_ERROR_NO_ASSERT(GetOverlappedResult);
return FALSE;
}
if ( 0 == dwBytesTransferred )
{
CancelIoEx(hFile, pOverlapped); // is this neccessary?
}
I refer the MSDN document, but no description for this condition.
thanks in advance.
your operation is finished (failed) with STATUS_TIMEOUT - this is final status and operation complete. you not need and can not cancel it - it finished. that GetOverlappedResult return TRUE and not set error code - this is only bad (I be say error) design of this win32 api. it unconditionally return TRUE and not set last error if (0 <= status). as result it wrong process STATUS_TIMEOUT (I think you worked with serial (com) port).
so formal answer:
your operation finished.
you should not call CancelIo
however i think that use GetOverlappedResult for asynchronous i/o at all no sense. need use apc or iocp completion.