How to put an if condition with a anchor tag value


#1

Suppose if i what to click one button depending on one condition, how could i do that ?

if Add Product then i click Button1
else if Out of Stock then i wont click

How i put this condition as i need to get this anchor tag value ?


#2

Hi Titus,

not sure if you are still using XML script test cases or Java code already, so I will provide an answer for both ways.

For script test cases, use a helper module with the click command in it. In the module call editor configure a JS expression as condition so the module will be called only if the condition is satisfied. The necessary script code looks like so:

    storeText                  css=...      varButtonText
    clickButtonHelperModule    IF "${varButtonText}" === "Add Product"

See here (section Script Developer) for more info on conditional module calls.

In Java, the code is a bit more straightforward:

    if (getText("css=...").equals("Add Product"))
    {
        click("css=...");
    }

Make sure that you use XLT 4.10.x as only this version provides the getText() method. Again, see here (section Framework) for more information.


#3

Hello J…!

Ya thanks very much…

I am using 4.9.3

How to upgrade to 4.10.x ??

Can I replace the folders after downloading ?

Which all folders need to be upgraded ?

Since I renamed the previously downloaded 4.9.3 and renamed that folder to project name