#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