Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2445
    aquilino morales
    Guest

    i need to click an item only if it is found to be on the page.
    is there an IF found() function?

    #2446
    Andrei
    Guest

    Hello,

    Yes, EveryStep Scripting tool supports IF() function.

    Examples are below:

    1. Immediate element search:

    // script_version=3.0; everystep_version=4.0.5987.31353; date=5/23/2016; Chrome=35.0.1916.157
    Tabs.SetSize (1768, 714);
    DMBrowser tab0 = null;
    Step (1, “CNN – Breaking News, U.S., World, Weather, Entertainment & Video News – http://edition.cnn.com/”);
    tab0 = Tabs.NewTab ();
    tab0.GoTo (“http://cnn.com”);

    string[] xpaths = new string[] { “//SPAN[normalize-space()=\”Is Austria about to elect a far-right candidate as president?\”]”,
    “//SPAN[normalize-space(text())=\”Is Austria about to elect a far-right candidate as president?\”]”,
    “//BODY/DIV[4]/SECTION[1]/DIV[2]/DIV/DIV[2]/UL/ARTICLE[1]/DIV/DIV[2]/H3/A/SPAN[1]” };
    if (tab0.Contains(xpaths))
    {
    tab0.Span (xpaths[0], xpaths[1], xpaths[2]).Click ();
    }

    Step (2, “Austria presidential election: Far-right candidate has slim lead – CNN.com – http://edition.cnn.com/2016/05/23/europe/austria-presidential-election/index.html”);
    tab0.Navigating (“http://edition.cnn.com/2016/05/23/europe/austria-presidential-election/index.html”);

    2. Waiting for an element, and if an element appears (during 50 sec), clicking it:

    // script_version=3.0; everystep_version=4.0.5987.31353; date=5/23/2016; Chrome=35.0.1916.157
    Tabs.SetSize (1768, 714);
    DMBrowser tab0 = null;
    Step (1, “CNN – Breaking News, U.S., World, Weather, Entertainment & Video News – http://edition.cnn.com/”);
    tab0 = Tabs.NewTab ();
    tab0.GoTo (“http://cnn.com”);

    string[] xpaths = new string[] { “//SPAN[normalize-space()=\”Is Austria about to elect a far-right candidate as president?\”]”,
    “//SPAN[normalize-space(text())=\”Is Austria about to elect a far-right candidate as president?\”]”,
    “//BODY/DIV[4]/SECTION[1]/DIV[2]/DIV/DIV[2]/UL/ARTICLE[1]/DIV/DIV[2]/H3/A/SPAN[1]” };
    if (tab0.WaitForElement(xpaths))
    {
    tab0.Span (xpaths[0], xpaths[1], xpaths[2]).Click ();
    }

    Step (2, “Austria presidential election: Far-right candidate has slim lead – CNN.com – http://edition.cnn.com/2016/05/23/europe/austria-presidential-election/index.html”);
    tab0.Navigating (“http://edition.cnn.com/2016/05/23/europe/austria-presidential-election/index.html”);

    Feel free to contact us if you need any help

    #2785
    Andrew
    Guest

    Hallo,
    is it possible to modify the timeout for WaiForElement (if(tab0.WaitForElement(“…”)) ?
    Many thanks
    Andrea

    #2787

    Hello Andrea
    Yes, you should be able to modify it. In case you can’t, click setting button at the top right corner of the application (wrench) -> Advanced Settings -> Miscelaneous tab -> Allow to edit script manually

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