我正在尝试使用Python登录到一个网页。但是,我没有得到正确的回答。输入框位于web中的HTML表下。你知道吗
这是我在网上查了一些教程后尝试的。你知道吗
driver.find_element_by_xpath("//table[5]/tbody/tr[1]/td[2]/input").send_keys("hi")
HTML代码:
<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>
我感兴趣的是挑选input class = "subject"
处的元素,这是第五个表。你知道吗
以下是从Chrome检查器复制的xPath代码:
/html/body/form/table[5]/tbody/tr[1]/td[2]/input
要将字符序列发送到与文本用户ID相关联的login
<input>
元素,必须诱导WebDriverWait,使元素可单击,并且可以使用以下任一方法解决方案:可以使用下列Locator Strategies之一:使用
CSS_SELECTOR
:使用
XPATH
:注意:必须添加以下导入:
下面是您可以使用的xpath。你知道吗
您还可以使用屏幕截图中显示的其他xpath。你知道吗
相关问题 更多 >
编程相关推荐