I am new to Selenium. I just want to send keys to a username text box and send a tab key both at a time so that text box can check for availability of username.
Try this code:
WebElement userName = pathfinderdriver.switchTo().activeElement();
userName.sendKeys(Keys.TAB);
List<WebElement>itemNames = wd.findElements(By.cssSelector("a strong"));
System.out.println("No items in Catalog page: " + itemNames.size());
for (WebElement itemName:itemNames)
{
System.out.println(itemName.getText());
}
I have found that creating a var to hold the WebElement
and the call the sendKeys()
works for me.
WebElement speedCurrentCell = driver.findElement(By.id("Speed_current"));
speedCurrentCell.sendKeys("1300");
I believe Selenium now uses Key.TAB
instead of Keys.TAB
.
Try this, it will surely work:
driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("UserName" + Keys.TAB);
For python selenium,
Importing the library,
from selenium.webdriver.common.keys import Keys
Use this code to press any key you want,
Anyelement.send_keys(Keys.RETURN)
You can find all the key names by searching this selenium.webdriver.common.keys
.