Giter Club home page Giter Club logo

Comments (4)

kensoh avatar kensoh commented on August 19, 2024

Hi @thim81 yes, you can use below statement directly as TagUI will recognize the ; at the end of the line and interpret it as JavaScript. Using var is not wrong but in many cases, defining as local variable (for example in a popup step or frame step) will make it inaccessible in later parts of your automation. In general, defining directly using variable_name = value; is easier to make it accessible throughout.

project_name = "MarcoPolo" + Math.floor(Math.random()*200);

Sample automation flow 9 has some more examples of using variables -
https://github.com/tebelorg/TagUI/blob/master/src/samples/9_misc

from tagui.

thim81 avatar thim81 commented on August 19, 2024

Hi @kensoh,

You were right removing the var helped with the strange behaviour that sometimes the variable became undefined

Thanks for the great help.

from tagui.

kensoh avatar kensoh commented on August 19, 2024

Adding on for future reference by other users the technical reason for that -

TagUI converts the natural-language-like syntax into CasperJS syntax JavaScript code to run automation. So a simple 1 line step in many cases will be converted into a more elaborate code block which does auto-waiting of the web element to appear, error handling and timeout when it does not appear, and taking the action when it appears.

Using var declares a local variable within the context of that particular code block, which may allow the variable to be accessed directly if the reference happens within the same code block. But that will most likely fail in subsequent steps, unless the next steps are simple steps such as echo which does not really do all those handling of web element.

Declaring directly using variable_name = value; is recommended and should make it accessible throughout the automation steps.

from tagui.

kensoh avatar kensoh commented on August 19, 2024

Added 2 commits related to this issue. Readme improvement to show how to define variable. And a new commit to simply recognize a = 1 as a valid statement to define variable. So that ; is not needed at the end. Commit comments below with more info, especially the note why where possible TagUI tries to throw error if it is not valid JavaScript code.

#30 - add variable_name step to show how to define a variable manually for use

#30 - set variable without typing ; at the end
; is used to detect that it is a valid JavaScript code
variable assignments are so often used that detecting = should be
acceptable, since that check is done at the very end of checking for
TagUI steps and other JavaScript keywords.

So the following will now work and be more convenient. Update readme
only when making new release and packaged installations.

a = 1
b = ‘b’
c = ”c”

Adding on, reason for JavaScript checking instead of taking anything
that is not TagUI step as JavaScript is to try to catch as much user
error as possible before even running an automation flow. This speeds
up development time rapidly without going through all the steps during
automation just to run into a user code error.

from tagui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.