How to set keyboard_enter_text timeout at calabash? - calabash

the problem is that i am trying to write a large text using the keyboard_enter_text and everytime this code runs it stops at the half and start again, after sometime it gives me the timeout error.
And I write an large post into post field # features/step_definitions/my_first_steps.rb:27
Time out waiting for UIAutomation run-loop for command uia.typeString('new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test new post test ', ''). Waiting for index:3 (RunLoop::TimeoutError)
./features/step_definitions/my_first_steps.rb:31:in `/^I write an large post into post field$/'
features/add_post.feature:19:in `And I write an large post into post field'
I already tried to write at the text field using set_text, but it is deprecated.
How can i solve that?
Thanks in advance.

We have started to see this more often on views with deep view hierarchies.
Calabash traverses the entire view hierarchy before typing. It does this because of bugs in UIAutomation. Long time Calabash users will recall the days when strings were incorrectly typed, characters were skipped or duplicated, or typing crashed the app.
The fix was gather as much information as possible about the view hierarchy before typing.
The workaround is to call:
uia("uia.typeString('String to type')")
The downside is that you will not get any of the error checking that Calabash provides. We are investigating this issue.

Yeah there is some time out issue with run loop, there is work around if want to type long string. you can use same string reduce length and enter three time like this:
Then I use the native keyboard to enter "new post test new post test new post test new post " into the "Email" input field
Then I use the native keyboard to enter "new post test new post test new post test new post " into the "Email" input field
Then I use the native keyboard to enter "new post test new post test new post test new post " into the "Email" input field

Related

Creating GET/POST services Ocsigen

I am building a app using Ocsigen, this app will not be connected to a database and the goal is to copy the content from the main website to here. (i am using curl to do Get requests)
So my problem here is, I am trying to do a "log in" with a user, and I want to build a service that saves to my code the username and the password that is introduced by the user. Then I could use the username and the password to do the GET request to the main website.
My problem it's only one, I have tried a lot of ways to build a service that saves this two strings but I can't figure out a way.
I did a lot of diferent tries and my last one I did something like the following:
let save_data =
Eliom_registration.Action.create
~meth:
(Eliom_service.Post
(Eliom_parameter.unit,
Eliom_parameter.string "username"))
~path:Eliom_service.No_path
(fun () username -> username)
Based on an example that Ocsigen has on their website but I doesn't work...
I created a form that is successfully executing the services I created, but the service is never doing what I need.
Sorry if I explained badly the situation... Is any idea how to solve this problem? I am going in the wrong way?
Thnx!
PS: I have also tried to edit the Os_services.connect_service form the Ocsigen-Start src folder, and I guess that I have to do a Post Service to this case, but again I failed to do what I want.
I think what you are looking for is Eliom_reference, that is if you wish to keep the information stored for later.
https://ocsigen.org/eliom/api/server/Eliom_reference
I'm a little bit rusty when it comes to Eliom but it would look like this:
let current_username : string option Eliom_reference.eref =
Eliom_reference.eref ~scope:Eliom_common.default_process_scope None
let save_data = Eliom_registration.Action.create
~meth:(Eliom_service.Post
(Eliom_parameter.unit,
Eliom_parameter.string "username"))
~path:(Eliom_service.No_path)
(fun () username -> Eliom_reference.set current_username (Some username))

Rails: How to write correct POST integration test (without special testing frameworks)

I am trying to write a simple integration test in Rails (following suggestions of "Agile Web Development with Rails 4", Chapter 13.2) without frameworks such as Capybara, RSpec etc. . GET requests are straight forward and produce no errors, whereas POST causes trouble. I have two models "entries" and "items", where an item has many entries. I would like to POST an entry and the corresponding item was handed over as param. So I am trying the following:
post "/entries", entry: {item: items(:one), value: 12, date: '2015-09-15', min_quantity: 22000, max_quantity: 3000000, country_id: 1}
assert_template :show
This produces:
1) Failure:
...
expecting <"show"> but rendering with <["entries/_form", "entries/new", "layouts/application"]>
which tells me that no entry was created, because in this case the controller redirects to method new (scaffold standard). So, how can I correctly create an entry using POST. Some more details:
I tried to leave out item: items(:one) since in the browser this needs not be submitted manually
I checked the model - and in fact no entry was created
I also produced a unit test to check on this very entry data and is passes
post_via_redirect does no better
Does anyone see my problem or have an example for a POST integration test which corresponds to a simple form including one parameter which is programatically set upfront? Thanks in advance!
I finally found the solution: there is a slight difference between unit tests and integration tests. While in unit tests you can refer to the referenced model by item: items(:one) in integration tests you must be precise like item_id: items(:one).id, which is the exact name of the data field in the model and database.
The exact details behind the scenes I do not know - maybe someone can comment and further enlighten me.

Django - Unit Testing an AdminForm

I am very new to unit testing and am probably doing something wrong, but when I simulate a post to update a model via the admin backend it seems like my save_model method in my AdminForm isn't being called. I am trying to test this method - what am I doing wrong?
My second, less relevant question is in general how can I make sure a method is being called when I use unit testing? Is there some way to list all the methods that were hit?
Below is the code my test is running. In my save_model method in my AdminForm for this model, I set this model's foobar attribute to the username of the currently signed in user. Below is my test:
self.client = Client()
self.client.login(username='username',password='password')
# self.dict is a dictionary of field names and values for mymodel to be updated
response = self.client.post('/admin/myapp/mymodel/%d/' % self.mymodel.id, self.dict)
self.assertEqual(response.status_code,200) # passes
self.assertEqual(self.mymodel.foobar,'username') # fails
self.client.logout()
It fails because it says that self.mymodel.foobar is an empty string. That was what it should have been before the update. No value for foobar is passed in the self.dict but my save_model method is designed to set it on its own when the update happens. It is also worth noting that my code works correctly and save_model seems to work fine, just my test is failing. Since I am a total noob at TDD, I'm sure the issue is with my test and not my code. Thoughts?
From the code it looks like the problem is that, after posting the form, you don't reload self.mymodel from the database. If you hold a reference to a model object stored in the database, and one or more of the fields on that object is changed in the database, then you will need to reload the object from the database to see the updated values. As detailed in this question, you can do this with something like:
self.mymodel = MyModelClass.objects.get(id=self.mymodel.id)
To answer your second question, probably the most useful way to see what is happening would be to use logging to output what is happening in your save_model method - this will not only help you debug the issue during testing, but also if you encounter any issues in this method when running your application. The django guide to logging gives an excellent introduction:
https://docs.djangoproject.com/en/dev/topics/logging/

Load testing with SOAP UI

I have a SOAP UI 4.5.1, I have made a load test, it is working fine. My problem is that I run the same request every time and I need to change the values of the soap request I am sending.
For e.g. I have a block of my soap request:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
Provider ID: SHL
Project ID: SampleAssessment
Is there a way to make those values changing from some kind of interval?
For e.g.: Provider IDs [SHL, SLH, LHS]
Project IDs [SampleAssessment, TestAssessment, AnotherAssessment]
And with a load test I am making three request so that for the first request values looks like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
for the second like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SLH</ns:ProviderId>
<ns:ProjectId>TestAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
and so on...
Is there a way to make this happen with SOAP UI?
From my experience, you will need to use a Groovy Script step.
For example, if you have a step before your request that is a script, you can use something like:
context.setProperty("ProviderId", "SHL")
Then in your request, use:
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Of course, this doesn't buy you much by itself. There are few ways to vary what the context.setProperty("ProviderId", "SHL") line will set. You can create a collection and iterate over it using something like:
def providers = ['ABC', 'DEF', 'GHI', 'JKL']
providers.each() {
context.setProperty("ProviderId", it)
testRunner.runTestStepByName( "nameofteststep" )
}
Where "nameofteststep" is the name of the Soap Request test step. This might sound odd, but if you right click the test step and disable it, the groovy script will still be able to execute it but it will not run sequentially. By that I mean that the groovy script will run it 4 times, but it won't run a fifth time when the script is complete because it is after the script. Then you just need to keep in mind that each load test thread makes four requests, but I am pretty sure that the SoapUI statistics will take this into account for you... might want to keep an eye out for it, though.
Alternatively, you could check the 'threadIndex' and set a the context variable based on that. A bit like this here: Log ThreadCount.
You could also use a collection without a loop and increment an index that you save as a testcase property and send the string corresponding to the index.
Personally, I think the first way is the most straightforward but I can provide an example of the other ones if you like.
There is a simple way of doing this without writing a groovy script.
After creating a test case you should include the below test steps:
1-Data source
2-Request
3-Loop
Data source will read an excel file (or other data source methods such as XML, groovy, JDBC, gird .. however the excel is the simplest one).
You should include the datas (that you need to change within the request)
Within the test request you need the right click and select "get data" . please notice that your test request should be as below
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Then the last step is the "Loop" . This for returning to the first step until the data ends.
I hope this helps.

Django 1.4 formwizard TestCases

I'm trying to write tests for form wizard views django.contrib.formstools.wizard.views.CookieWizardView, and I'm not sure how to handle writing the sequential posts in the test cases:
#test_views.py
def test_wizard_pass(self):
response = self.c.post('/wizard/url/',first_form_post_dict)
self.assertContains(...)
response = self.c.post('/wizard/url/',second_step_post_dict)
self.assertRedirect(...)
I assume I need to change the second post data based on something from the first response or something to do with the cookie used for session management, I'm just not sure what.
The test cases for CookieWizardView can be found in django.contrib.formtools.tests.wizard.wizardtests.tests (line 216, view source here), including multiple sequential posts. You can study how these are implemented and implement your own test cases in a similar way.