Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Get API_JSON data in variable #41

Closed
thim81 opened this issue Aug 1, 2017 · 2 comments
Closed

Q: Get API_JSON data in variable #41

thim81 opened this issue Aug 1, 2017 · 2 comments
Labels

Comments

@thim81
Copy link

thim81 commented Aug 1, 2017

I'm trying to open a link that I get from an API reponse, but I'm missing something.

flow api

http://demo3796957.mockable.io/test

//api_config.header[0] = 'Header1: value1';
api http://demo3796957.mockable.io/test
echo api_result
echo 'Link - ' + api_json.link

{
    '+api_json.link+'
}

./src/tagui ./sample/test_api firefox test

Show the following output

ERROR - [LINE 11] cannot understand step '+api_json.link+'
ERROR - automation aborted due to above
@kensoh kensoh self-assigned this Aug 1, 2017
@kensoh kensoh added the query label Aug 1, 2017
@kensoh
Copy link
Member

kensoh commented Aug 1, 2017

Yes this is expected, TagUI works by letting users convey their intention through various steps + JS code as needed. It will check if the line starts with http:// or https:// to detect that user wants to access an URL. In this case '+api_json.link+' is a variable and it doesn't convey that intention, so it throws error. It should work if the URL is broken down to http://'+api_json.link+' etc where api_json.link is github.com/tebelorg/TagUI instead of https://github.com/tebelorg/TagUI.

@kensoh
Copy link
Member

kensoh commented Aug 1, 2017

Closing this issue for now, added some note on the other issue.

"Adding on, for eg in JavaScript, we can't really define a variable as a string JS statement, then type that variable on an empty line by itself to execute the statement. JS can use eval. For TagUI the parsing happens before the execution, when natural-language-syntax converts into JS code. Such replacements will work if they are provided from data tables, as it is still within control during parsing."

For above scenario and the data_test variable scenario, as long the http:// or https:// is not made part of the variable contents it should work when concatenated back. So that TagUI recognizes user intention is calling an URL when http://'+variable+' is used.

@kensoh kensoh closed this as completed Aug 1, 2017
kensoh added a commit that referenced this issue Aug 4, 2017
https://github.com/tebelorg/TagUI/issues/41 & https://github.com/tebelorg/TagUI/issues/37 - include http(s):// step to make it clearer the step keyword that is detected for url intention
https://github.com/tebelorg/TagUI/issues/40 - make it even clearer api_result is a text variable and api_json is a JSON object
https://github.com/tebelorg/TagUI/issues/39 - small adjustment to make api_config more obvious as a user missed that part
https://github.com/tebelorg/TagUI/issues/36 - update to further emphasize CasperJS assertions don't work with Chrome
https://github.com/tebelorg/TagUI/issues/30 - add variable_name step to show how to define a variable manually for use
https://github.com/tebelorg/TagUI/issues/29 - minor update to emphasize test option to use CasperJS test framework

- add (on new line) to // step to emphasize entering // on a new line. using click abc // user comment will fail as the comment part is being treated as part of the selector. XPath selector has // and there is no way to distinguish if accept // as denoting comment
@kensoh kensoh removed their assignment Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants