What if there's more than one...?

You're have probably wondering at some point what if there's more than one occurance of the object that you want to interact with on on the page? UI-licious intelligently infers from the previous steps to figure out what you meant to do next.

Let's take a look at Twitch's website for example where there's 3 "Log In" button on the same page, and let's imagine you're calling a friend who needs a bit of help logging into Twitch:

I.goTo("https://www.twitch.tv/")
I.click("Sign up")

I.see("Join Twitch today")
I.click("Log In") 
I.fill("Username", "brucewayne")
I.fill("Password", "supersecretpasswrod")
I.click("Log In") 
I.see("This username or password was incorrect. Please try again.")

Let's take a closer look at what's happening.

I.see("Join Twitch today")I.click("Log In")

Since you were just looking at the words "Join Twitch today", UI-licious tries to click on the "Log In" tab closer to those words.

I.fill("Username", "brucewayne")I.fill("Password", "supersecretpasswrod")I.click("Log In")

And since you were just filling up this form, UI-licious will pick the "Log In" button to submit the form, naturally.

That said, when there are multiple similar objects, you can use this mechanism and use I.see to indicate to UI-licious which parts of the page you are moving on to test. This can come in really handy when you want to interact with tables of records for example:

I.goTo("https://example.uilicious.com/employee_age_table.html")
I.see("Kate")I.fill("Age", "28")
I.click("Update")
I.see("Updated Kate")

When you are ready, click Next below.