I am trying to login into a webpage using Python Selenium. However, I am not getting the correct response. The input box is under an HTML table in the web.
This is what I have tried after looking up some tutorials online.
driver.find_element_by_xpath("//table[5]/tbody/tr[1]/td[2]/input").send_keys("hi")
The HTML code:
<html>
<head>...</head>
<body>
<form name="form" action method="post" onsubmit>
<table border="0" , width="100%" cellpadding="0" cellspacing="0">...</table>
<table border="0" , width="100%" cellpadding="0" cellspacing="0">...</table>
<table border="0" , width="100%" cellpadding="0" cellspacing="0">...</table>
<table align="center" border="0" width="100%" cellpadding="0" cellspacing="0">...</table>
<table align="center" border="0" width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr align="left">
<td class="mandatory"> USER ID</td>
<td class="normal">
<input class="subject" type="text" name="username" size="35" maxlength="10" onkeypress="navigate();">
</td>
</tr>
</tbody>
</table>
I am interested to pick out the element at the input class = "subject"
, which is the fifth table.
The following is the xPath code copied from Chrome inspector:
/html/body/form/table[5]/tbody/tr[1]/td[2]/input