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

Steps { and } should not be used for step / code blocks #26

Closed
kensoh opened this issue Jun 20, 2017 · 3 comments
Closed

Steps { and } should not be used for step / code blocks #26

kensoh opened this issue Jun 20, 2017 · 3 comments
Labels

Comments

@kensoh
Copy link
Member

kensoh commented Jun 20, 2017

ISSUE - In release v1.8, steps { and } are introduced to define steps and code blocks. This adds convenience and powerful automation when used with if/for/while/popup/frame.

The idea is replacing { with

// start of code block
{casper.then(function() {

And replacing } with

})}; // end of code block

The above replacements and some tracking logic will automatically take care of CasperJS code blocks formatting. However, as { and } can also be used in JavaScript to define code blocks, there can be situations where developers want to define custom functions or events which above auto-replacement will break their code. Unless they use js step to explicitly tell TagUI to treat that line as pure JavaScript and not to parse it as a TagUI step.

There should be a better way so that developers do not have to type js { or js } to explicitly treat the line as JavaScript, and normal users can define step/code blocks easily. Maybe checking [ and ] instead as the single character on the line as markers for start and end of step/code block.

@kensoh
Copy link
Member Author

kensoh commented Jun 20, 2017

Reclassifying more appropriately as a bug because v1.8 may break the original design of users who have used { and } to mean traditional JavaScript code blocks.

@kensoh
Copy link
Member Author

kensoh commented Jun 20, 2017

Thinking through, it seems that there is probably no existing use case which will encounter an issue with the above auto-replacement to casper context blocks. This is because lines in the automation flows are already by default in casper context.

Developers wanting to add custom functions would have to define them in tagui_header.js. Unless they manually close the casper context, define them, and reopen casper context. In that case using js step to explicitly declare as JavaScript code would work.

Readme should officially include js step. This should be a good balance between pro-developers flexibility and quick prototyping convenience.

@kensoh
Copy link
Member Author

kensoh commented Jun 20, 2017

Closing and changing to enhancement category - adding js step officially to readme documentation.

kensoh added a commit that referenced this issue Aug 7, 2017
- improve code block and loop handling. to process { and } into casper
blocks if the lines start with { or }. otherwise will cause many valid
javascript code to throw error. such as when using chrome_step or
setting api_config. with this change, the js step is not needed to
avoid those errors. add more error checking for loops to show error at
parsing if { is written on the same line. this will guide users to type
{ on the next line to be auto-parsed into casperjs blocks.

- updated details for steps that are not relevant/supported in live
mode, add support for live mode navigate to url when running chrome
browser. for phantomjs, set window.location.href or using
casper.thenOpen will not work when event loop is not yet passed back to
main 'thread'. also checked that recent changes to steps have been
mirrored to live mode.

- add code in positive test to auto-cleanse local folder path instead
of manually searching and replacing
kensoh added a commit that referenced this issue Aug 7, 2017
- fixed bug that can mess up complicated flows with multiple loop calls

- frame and popup previously don’t work in for loop. now it can be used
in for loop. however, no code blocks for frame / popup. just call
multiple times in the for loop. can become very messy and harder for
user to debug issues if try to implement that now.

frame name
step a
frame name
step b
@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

1 participant