user1338101
user1338101

Reputation: 71

How to randomly select and click a link from a group of links in a webpage using selenium IDE?

I am new to selenium IDE. After searching for hours, I can't find the way to do what i want. What I need to do is quite simple. I have an html page with a lot of bookmarks. I can work with it online or offline. so I need the script to pick randomly a link from the group of links. then click that link. What's the easier way to do that?

note: Using firefox and selenium IDE 2.4.0

thanks.

Upvotes: 2

Views: 1583

Answers (1)

ddavison
ddavison

Reputation: 29032

My best guess would be to use the addScript command and delegate your task to JavaScript. I have high doubts that Selenium IDE alone will solve your problem.

Here is some pseudo-code

Target:

Command: addScript

Value:

var links = document.getElementsByTagName("a");
var randNum = Math.rand(0, links.length());
links[randNum].click()

Upvotes: 2

Related Questions