Created
July 17, 2015 10:41
-
-
Save outofrange/d92be829255120134bd2 to your computer and use it in GitHub Desktop.
SSCCE for a potential Selenium bug: sendKeys() doesn't send keys (https://github.com/SeleniumHQ/selenium/issues/805)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package repro; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.ie.InternetExplorerDriver; | |
import org.openqa.selenium.ie.InternetExplorerDriverService; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
public class SendKeysBug { | |
public static void main(String[] args) { | |
System.setProperty(InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY, "C:\\tmp\\IEDriverServer.exe"); | |
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); | |
ieCapabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true); | |
WebDriver driver = new InternetExplorerDriver(ieCapabilities); | |
driver.get("file:///C:\\tmp\\site.html"); | |
long end = System.currentTimeMillis() + 30 * 60 * 1000; | |
int i = 0; | |
final WebElement field = driver.findElement(By.id("input")); | |
while (System.currentTimeMillis() < end) { | |
final String expected = String.valueOf(i++); | |
field.clear(); | |
field.sendKeys(expected); | |
final String actual = field.getAttribute("value"); | |
if (!expected.equals(actual)) { | |
System.out.println(expected + " isn't equal to " + actual); | |
break; | |
} | |
} | |
driver.quit(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- saved from url=(0014)about:internet --> | |
<html><body><input id="input"/></body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment