• This topic has 3 replies, 2 voices, and was last updated 4 years ago by Support.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2508
    Oliver
    Guest

    Is there a way to assign a variable such that I can have my script click on a link whose text matches a text string?

    Better yet, is there a way that I can have the script read in a set of variables from a text or Excel file and perform steps based on those variables?

    e.g. if I want to get the batting average for each player on the Red Sox team, can I set up a list of player names, and have the script loop through the list, get each name, navigate to a website, search for that player name, find the element on the website which corresponds to the player’s batting average and then populate my file with the batting average next to the player’s name?

    #2509

    Hello,

    First of all EveryStep application is designed for automated website functionality monitoring, not data collection, so accessing local files (reading or writing) is prohibited due to security concerns.

    Still, script can be modified within reason using valid C# code.
    For example, you can define an array of values to use them later at script, like

    string[] PlayerName = {
    “value1”,
    “value2”,
    “value3”,
    };

    foreach (string Name in PlayerName)
    {
    tab0.TextField (“//INPUT[@ID=\”playername\”]”, “(//INPUT[@TYPE=\”text\”])[1]”).TypeText (Name);
    }

    Here’s some more examples of custom code for the reference:
    https://www.dotcom-monitor.com/wiki/everystep/everystep-sample-c-code-editing-in-a-script/

    Kind regards.

    #2707
    Andrea
    Guest

    I tried to run a script where I had previously pasted the code below:

    // script_version=3.0; everystep_version=4.0.5953.25078; date=4/19/2016; IE=11.0.9600.17126
    Tabs.ConfigureIEVersion (BrowserMode.IE11, DocumentMode.IE11Emulate);
    Tabs.SetSize (1768, 651);
    DMBrowser tab0 = null;
    Step (1, “The input element – HTML5 tutorial – http://www.html-5-tutorial.com/input-element.php“);
    tab0 = Tabs.NewTab ();
    tab0.GoTo (“http://www.html-5-tutorial.com/input-element.php“);
    // produces random number in range from 18 to 120
    int r = (new Random(DateTime.Now.Second)).Next(18, 121);
    tab0.TextField (“//INPUT[@TYPE=\”number\”]”, “//INPUT[@NAME=\”age\”]”, “//B[normalize-space()=\”Age:\”]/..//INPUT”).TypeText (r.ToString());

    I found the code in the page EveryStep: Sample C# Code Editing in a Script – Editing scripts in EveryStep

    I got an error dealing with the compiler and I see that the ‘int’ declaration/definition is highlighted in red.
    Do I need to perform some other actions in order to let the C# commands be compiled and run correctly?
    Thank you in advance.

    Andrea

    #2708
    Support
    Guest

    Hello,

    Some double quotes signs were in incorrect format, c# code is Ok. So, here is the script which worked for us:

    // script_version=3.0; everystep_version=4.0.5953.25078; date=4/19/2016; IE=11.0.9600.17126
    Tabs.ConfigureIEVersion (BrowserMode.IE11, DocumentMode.IE11Emulate);
    Tabs.SetSize (1768, 651);
    DMBrowser tab0 = null;
    Step (1, “The input element – HTML5 tutorial – http://www.html-5-tutorial.com/input-element.php”);
    tab0 = Tabs.NewTab ();
    tab0.GoTo (“http://www.html-5-tutorial.com/input-element.php”);
    // produces random number in range from 18 to 120
    int r = (new Random (DateTime.Now.Second)).Next (18, 121);
    tab0.TextField (“//INPUT[@TYPE=\”number\”]”, “//INPUT[@NAME=\”age\”]”, “//B[normalize-space()=\”Age:\”]/..//INPUT”).TypeText (r.ToString ());

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.