15

I have a checkbox that I'm trying to click in Selenium IDE - but only if it's not already active.

I'm using Selenium IDE to create my tests, and htmlsuite to run them - anyone know how I can use an "if" in those?

Pavel Janicek
  • 14,128
  • 14
  • 53
  • 77
Hippyjim
  • 2,520
  • 6
  • 38
  • 54

2 Answers2

11

You'll have to download the Flow Control plugin for Selenium IDE from the official page (aaaall the way down).

The most useful link I found is this one, because it has a complete example in it: http://selenium.10932.n7.nabble.com/if-else-statement-td4370.html

Anyway, there's also a documentation and author's blogpost explaining something more.


The only alternative I know about is implementing the whole logic in javascript - including the test steps. It's possible, it's a little bit harder to get right, but if you'll end up stuck with IDE without plugins, it might be your only save:

var value = this.browserbot.findElement("id=someInput").value;
if (value == "Slanec is the best!") {
    this.browserbot.findElement("id=someButton").click();
}
Kwadz
  • 2,206
  • 2
  • 24
  • 45
Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
  • 1
    thanks for the links - I was hoping to avoid plugins as I have no control over the selenium server on the testing machine, but this looks like the only way – Hippyjim Jul 01 '12 at 16:17
  • @Hippyjim I edited the answer with the alternative solution. But I think using IDE and a plugin is way better ;) – Petr Janeček Jul 01 '12 at 16:29
  • I have two questions which may not be solved by a plugin. Can you help me with those - http://stackoverflow.com/questions/17358228/java-and-selenium-for-web-form-filling – david blaine Jun 28 '13 at 06:47
  • The second one is - http://stackoverflow.com/questions/17357580/is-it-possible-to-do-this-selenium-firefox-ide – david blaine Jun 28 '13 at 06:47
2

Try this:

**storeTextPresent || [some_value] || [variable_name]**

**gotoIf || storedVars['variable_name']** == true || **goto_label_name**

// Command to execute if the condition is not met

**label goto_label_name** 

// This is where the script will jump to when // Command to execute if the condition is met, this part may be off course unrelated to the initial condition

You'll need to have installed the Flow Control plugin for Selenium IDE.

kripindas
  • 480
  • 2
  • 7
  • 21
bobafett
  • 107
  • 1
  • 8
  • This would have been a great answer, assumidn the user has sideflow, but didnt want to have to create an extra label, but slanecs avoids using th e return label – blamb Jun 21 '16 at 22:01