Using Selenium WebDriver in Java, I am trying to automate a functionality("Ensure that actionable elements are keyboard accessible") where I have to go through all the interactive elements (links, radio button, check box, buttons etc) in a webpage by pressing keyboard key 'TAB'. It's under accessibility testing. I'm trying to automate 'keyboard access' from the accessibility testing.
Please suggest me Selenium WebDriver script
Using the sendkeys method of the WebElement requires a WebElement to send it to which kind of negates the test in the first place. Using an actions object would probably work.So my script would be something along the lines of
static void goThroughTabs(){
WebDriver driver = new FirefoxDriver();
Actions action = new Actions(driver);
int NumberOfElements = 10; //This is the number of elements to test
for(int Counter = 0; Counter < NumberOfElements; Counter++){
action.sendKeys(Keys.TAB).build().perform();
}
}
The bigger problem would be to make sure that it tabbed over every Element but for a problem like this I'd need more information regarding the specifics of the test.