In my last post, I showed a solution how to autofocus, Escape key capture and page redirection in jQuery. So there is a quest how to automatically test it?
In the following codes snippet of the functional test in Groovy, a rapid script language of its uncle Java, showing how to achieve this in a simple straight-forward way. The codes is based on Selenium library.
package somewhere.in.the.rainbow
import static org.junit.Assert.assertThat
import static org.junit.Assume.assumeTrue as assume
import static org.hamcrest.CoreMatchers.*
import org.junit.Test
import org.junit.Ignore
import org.openqa.selenium.Keys
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import somewhere.in.the.rainbow.pages.BarcodeEntryPage
import somewhere.in.the.rainbow.pages.LoginPage
import somewhere.in.the.rainbow.pages.OtherServicesPage
import somewhere.in.the.rainbow.Constants
» Read more: A functional test in Groovy to test Autofocus, Escape key capture and page redirection