Assign text input value to a variable in Calabash - calabash

I'm evaluating Calabash coming from an Appium & Selenium background.
In Selenium i can simply assign the .attribute("value") to a variable and then do what I want with it. I'm looking for something similar in Calabash.
Specifically in an Android app (although I am looking for a cross platform solution) I have an EditText that I can query with :text and I can see the value in the output i.e.
irb(main):008:0> query("EditText",:text)
[
[0] "17512"
]
How can I perform the same function as a step definition in calabash and assign the output (i.e. 17512) to a variable?
Any advice is much appreciated.

This post helped me get what I needed: https://sqa.stackexchange.com/questions/8385/how-to-get-the-text-to-verify-for-edittext-in-calabash-android
Particularly actual_email = query("EditText id:'txt_email'", :text).first

Related

From local scrapy to scrapy cloud (scraping hub) - Unexpected results

The scraper I deployed on Scrapy cloud is producing an unexpected result compared to the local version.
My local version can easily extract every field of a product item (from an online retailer) but on the scrapy cloud, the field "ingredients" and the field "list of prices" are always displayed as empty.
You'll see in a picture attached the two elements I'm always having empty as a result whereas it's perfectly working
I'mu using Python 3 and the stack was configured with a scrapy:1.3-py3 configuration.
I thought first it was in a issue with the regex and unicode but seems not.
So i tried everything : ur, ur RE.ENCODE .... and didn't work.
For the ingredients part, my code is the following :
data_box=response.xpath('//*[#id="ingredients"]').css('div.information__tab__content *::text').extract()
data_inter=''.join(data_box).strip()
match1=re.search(r'([Ii]ngr[ée]dients\s*\:{0,1})\s*(.*)\.*',data_inter)
match2=re.search(r'([Cc]omposition\s*\:{0,1})\s*(.*)\.*',data_inter)
if match1:
result_matching_ingredients=match1.group(1,2)[1].replace('"','').replace(".","").replace(";",",").strip()
elif match2 :
result_matching_ingredients=match2.group(1,2)[1].replace('"','').replace(".","").replace(";",",").strip()
else:
result_matching_ingredients=''
ingredients=result_matching_ingredients
It seems that the matching never occurs on scrapy cloud.
For prices, my code is the following :
list_prices=[]
for package in list_packaging :
tonnage=package.css('div.product__varianttitle::text').extract_first().strip()
prix_inter=(''.join(package.css('span.product__smallprice__text').re(r'\(\s*\d+\,\d*\s*€\s*\/\s*kg\)')))
prix=prix_inter.replace("(","").replace(")","").replace("/","").replace("€","").replace("kg","").replace(",",".").strip()
list_prices.append(prix)
That's the same story. Still empty.
I repeat : it's working fine on my local version.
Those two data are the only one causing issue : i'm extracting a bunch of other data (with Regex too) with scrapy cloud and I'm very satisfied with it ?
Any ideas guys ?
I work really often with ScrapingHub, and usually the way I do to debug is:
Check the job requests (through the ScrapingHub interface)
In order to check if there is not a redirection which makes the page slightly different, like a query string ?lang=en
Check the job logs (through the ScrapingHub interface)
You can either print or use a logger to check everything you want trough your parser. So if you really want to be sure the scraper display the same on local machine and on ScrapingHub, you can print(response.body) and compare what might cause this difference.
If you can not find, I'll try to deploy a little spider on ScrapingHub and edit this post if I can manage to have some time left today !
Check that Scrapping Hub’s logs are displaying the expected version of Python even if the stack is correctly set up in the project’s yml file.

React Jest, Enzyme remove or hide Received part

I'm exploring tests for my React build and in general - all works as expected.
I have question about "Received" info part of test.
Do I really need whole info? Because it looks redundant.
For example I do simple checking for DOM elements and expect to have 1 and got 2 - I'm happy with this part, but how can I hide all those spaghetti?
Jest part of package.json:
"jest": {
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
"unmockedModulePathPatterns": [
"react",
"enzyme",
"jest-enzyme"
]
},
There are a couple of things that you can do,
Check if the find elements exits like
expect(wrapper.find(".testing-purposes").exists()).toBe(true);
Check the length of the return elements like
expect(wrapper.find(".testing-purposes").length).toBe(2);
According to the documentation:
Use .toHaveLength to check that an object has a .length property
and it is set to a certain numeric value.
This is especially useful for checking arrays or strings size.
which doesn't seem to be the case for you
You are comparing the whole shallow rendered. The toHaveLength hasn't worked consistently for me.
Try:
expect(wrapper.find(".testing-purposes").length).toBe(2);

Viewstate Replacing error. [ViewStateException: Invalid viewstate. ]

Tried with JMeter: How to know why my regular expression extractor in JMeter is not extracting the data but still not able to replace my view-state, its throwing [ViewStateException: Invalid viewstate. ] error . Please check the attachment , an my script has not _EVENTVALIDATION .
enter image description hereViewstate
viwstate2
As i am observing from your attached image
You need to pass same `Reference name` as a value of __VIEWSTATE in Next request
First Cross verify, Is your correaltion is correct or not? (you can use debug sampler to check the correlation)
If yes, then first mistake is, you had given reference name as "VIEWSTATE" in below shown snapshot
But you are passing ${jsfViewState} in other snapshot, so correct it and pass same reference name i.e. ${VIEWSTATE}
It'll resolve your issue, if issue still persists then click on encode button beside Name-Value pair because sometimes there is some mismatch in encoding format between the response which we capture and the value which we have to pass
Don't be confused with ASP.NET ViewState and JSF Viewstate, they have similar nature but different underlying technologies and different parameter names
Given you correctly correlated the value, I believe you need to change __VIEWSTATE parameter name to javax.faces.ViewState and it should work.
See Testing a JSF Application with JMeter guide for a little bit more detailed explanation on the topic and How to debug your Apache JMeter script guide for some troubleshooting techniques.

How to enable Code Assist for ColdFusion builder 2.0.1?

I tried my best to enable the code assist in ColdFusion builder 2.0.1 but no luck.
I found two helping pages:
http://help.adobe.com/en_US/ColdFusionBuilder/2.0/Using/WS0ef8c004658c1089-554789f8121af8f0c8c-7ffb.html
and
http://help.adobe.com/en_US/ColdFusionBuilder/2.0/Using/WSf01dbd23413dda0e1736ebc1213a528ab0-7ffb.html#WS0ef8c004658c1089794dbeb6124c7814753-8000
what I am looking for is to let the coldFusion Builder assist me by auto-completing the REQUEST, SESSION, & APPLICATIONS variables. I tried the follow the instructions in the second link but it didn't work, maybe I wrote some incorrect data?
If any one managed to let it work, please help me.
Assuming you have set up the server correctly in CF Builder, it will talk to the server and cache the respond of what methods does a CFC have. (Console Tab: "Server is available. Getting server settings.")
E.g. If Person.cfc has property Name and Age with accessors=true, and you type p = new Person(), then "p." (Ctrl+Space) should see getAge(), getName(), setAge(), setName(). If you got that to work, you have set it up correctly.
As for variables in REQUEST, SESSION, & APPLICATIONS scopes, I think CFB would see if you have referenced them before on the same .cfm and may give you autocomplete, but don't count on it to be smart enough to know exactly what variables are there in the scopes.

Create complex-type variables for a Web Service Task

In SSIS, I already have a Web Service Task using a WSDL for sending SMS. I am indeed able to send SMS using this task.
I want supply values to this task from the database, such as Mobile Number, Message body, User ID, etc.
How can I create a complex type user variable that can be passed as input to a Web Service task?
It looks like the only answer is to change the web service to accept only simple types as parameters. I have scoured the web and there seems to be no way to dynamically create complex types for consumption by the input values in the web service task.
The more 'easy' way is to use the script component for bypassing variables to a web service. Check http://amolpandey.com/2016/09/26/ssis-script-task-to-obtain-geo-cordinates-from-address-text-via-google-api/ & http://www.sqlmusings.com/2011/03/25/geocode-locations-using-google-maps-v3-api-and-ssis/.
Tested and working. Using this task you can bypass the SSIS variables/parameters.
Example: Getting ID, addreess, zipcode, city, country from a table with an execute SQL Task. Change Resultset:Full result set on General tab. Then on resultset tab add Result_Name:0 & Variable_Name: User::YourObject. Then the next task will be a Forlooptask editor (Foreach ADO Enumerator ,Collection tab - Ado object source variable: User::YourObject, enumeration mode: rows in the first table, variable Mapping tab - Variable User::Id, 0 | address,1 etc.). Inside the Forlooptask editor you add a data flow task, which the source of this task will be a script component. If you be more specific about your logic,we may assist you more.
Okay so I came across the same problem. I needed to pass one parameter as complex type.
Create a Web Service task in your package.
Fill all the needed properties at General tab: HttpConnection and WSDFile
Fill properties in Input tab: Service, Method
Below click on Value, manually enter the value you need (mine is 2021-11-15)
Deploy and execute package to be sure everything is OK
After this easy steps go into folder where package is localated. Right click on package file (Package.dtsx) and select Open with > Notepad. With find function in notepad search the value you manually inserted.
The part which we are looking for looks in my case like this
<WSTask:ComplexValue>
<WSTask:ComplexProperty
WSTask:Name="date"
WSTask:Datatype="dateTime"
WSTask:ParamType="Primitive">
<WSTask:PrimitiveValue>2021-11-15</WSTask:PrimitiveValue>
</WSTask:ComplexProperty>
</WSTask:ComplexValue>
Finally I found what I was looking for. Now for the second part I needed to be that parameter changing by current date when I execute that package. In powershell I managed to write a code that change date part in string: <WSTask:PrimitiveValue>2021-11-15</WSTask:PrimitiveValue> to current date, everytime when the package is executed. The code looks like this:
$Now = Get-Date -Format "yyyy-MM-dd"
$Yesterday = (Get-Date).AddDays(-1).ToString("yyyy-MM-dd")
$file = ((Get-Content -path "C:\Package.dtsx" -Raw) -replace "<WSTask:PrimitiveValue>$Yesterday</WSTask:PrimitiveValue>", "<WSTask:PrimitiveValue>$Now</WSTask:PrimitiveValue>")
[System.IO.File]::WriteAllText("C:\Package.dtsx",$file)
# This part will execute the package #
dtexec.exe /f "C:\Package.dtsx"
After all this, I planned this script in Task Scheduler and it works.
In my case changing the type of request from complex to simple wasn't an option and all I needed was just one parameter to pass.
Hopes it gonna help somebody.