Last active
December 11, 2015 11:28
-
-
Save cpilsworth/4593464 to your computer and use it in GitHub Desktop.
selenium webdriver no element found error in internet explorer
http://stackoverflow.com/questions/14441048/selenium-webdriver-no-element-found-error-in-internet-explorer/14441408
This file contains hidden or 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
<table bgcolor="#ffffd0" cellPadding="1" cellSpacing="1" border=0 > | |
<tr> | |
<td width="5%"> </td> | |
<td width="30%"> </td> | |
<td width="65%"> </td> | |
</tr> | |
<tr> | |
<td> </td> | |
<td colspan="2"> | |
<FONT SIZE="3"><B>Log on</B></FONT> | |
</td> | |
<td> </td> | |
</tr> | |
<tr><td colspan=4> </td></tr> | |
<tr> | |
<td> </td> | |
<td class="form">User Name</td> | |
<td class="form"> | |
<input type="text" tabindex="0" size="22" name="username" autocomplete="off" /> | |
</td> | |
<td> </td> | |
</tr> | |
<tr> | |
<td> </td> | |
<td class="form">Password</td> | |
<td class="form"> | |
<input type="password" tabindex="0" name="password" size="22" autocomplete="off" /> | |
<!--<span id="spanCaps" class="PopupBox" style="margin-left:10;vertical-align:bottom;">Caps Lock is <b>ON</b></span>--> | |
</td> | |
<td> </td> | |
</tr> | |
<tr> | |
<td> </td> | |
<td> </td> | |
<td class="form" > | |
<span id="spanCaps" class="PopupBox">Caps Lock is <b>ON</b></span> | |
<input type="submit" name="submit" tabindex="0" value="Login"> |
This file contains hidden or 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 com.test; | |
import java.io.File; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.ie.InternetExplorerDriver; | |
public class SeleniumTest { | |
public static void main(String[] args) { | |
String SELENIUM_HOME = "C:/Users/cpilsworth/apps/selenium-2.28.0"; | |
String HTML_PAGE = "http://localhost:8080/selenium.html"; | |
File file = new File(SELENIUM_HOME + "/IEDriverServer.exe"); | |
System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); | |
WebDriver driver = new InternetExplorerDriver(); | |
driver.get(HTML_PAGE); | |
// Find by xpath | |
WebElement Name = driver.findElement(By.xpath("//input[@name='username']")); | |
Name.sendKeys(new String[]{"user"}); | |
WebElement Pass = driver.findElement(By.xpath("//input[@name='password']")); | |
Pass.sendKeys(new String[]{"pass"}); | |
// find by css selector | |
Name = driver.findElement(By.cssSelector("input[name=username]")); | |
Name.sendKeys(new String[]{"name"}); | |
Pass = driver.findElement(By.cssSelector("input[name=password]")); | |
Pass.sendKeys(new String[]{"word"}); | |
// By name | |
Name = driver.findElement(By.name("username")); | |
Name.sendKeys(new String[]{"1"}); | |
Pass = driver.findElement(By.name("password")); | |
Pass.sendKeys(new String[]{"2"}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment