HTML Code
<div id="all_transactions_for_account">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Deposit</th>
<th>Withdrawal</th>
</tr>
</thead>
<tbody>
<tr>
<td>2012-09-06</td>
<td>ONLINE TRANSFER REF #UKKSDRQG6L</td>
<td>984.3</td>
<td></td>
</tr>
<tr>
<td>2012-09-05</td>
<td>OFFICE SUPPLY</td>
<td></td>
<td>50</td>
</tr>
<tr>
<td>2012-09-01</td>
<td>ONLINE TRANSFER REF #UKKSDRQG6L</td>
<td>1000</td>
<td></td>
</tr>
</tbody>
</table>
Java code
public class Sample {
@Test
public void sampleMethod() throws InterruptedException
{
WebDriver driver;
driver= new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://zero.webappsecurity.com/login.html");
driver.findElement(By.id("user_login")).sendKeys("username");
driver.findElement(By.id("user_password")).sendKeys("password");
driver.findElement(By.name("submit")).click();
driver.findElement(By.linkText("Savings")).click();
WebElement e =driver.findElement(By.xpath(".//*[@id='all_transactions_for_account']/table/tbody/tr[2]/td[2]"));
System.out.println(e.getText());
}
}
Not only that single element,I not able to find any element in this page. Refer to screen
So please help me I spent more than 2 day but i can't find the solution.
Here are some changes what you need to do:
To work with Selenium 3.4.0 along with latest gecko driver 0.16 & Mozila Firefox 53.0, you need to download the gecko driver and save it. Mention the absolute location of gecko driver in System.setProperty
Finally your code will look like:
@Test
public void sampleMethod()
{
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
WebDriver driver= new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://zero.webappsecurity.com/login.html");
driver.findElement(By.id("user_login")).sendKeys("username");
driver.findElement(By.id("user_password")).sendKeys("password");
driver.findElement(By.xpath("//input[@name='submit']")).click();
}
Let me know if this helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.