- This topic has 3 replies, 2 voices, and was last updated 6 years, 7 months ago by EveryStep Support.
-
AuthorPosts
-
May 19, 2016 at 1:11 pm #2445aquilino moralesGuest
i need to click an item only if it is found to be on the page.
is there an IF found() function?May 23, 2016 at 10:04 am #2446AndreiGuestHello,
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
May 25, 2018 at 6:19 am #2785AndrewGuestHallo,
is it possible to modify the timeout for WaiForElement (if(tab0.WaitForElement(“…”)) ?
Many thanks
AndreaMay 25, 2018 at 11:48 am #2787EveryStep SupportModeratorHello 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 -
AuthorPosts
- You must be logged in to reply to this topic.