擅长:python、mysql、java
<p>您提供的xpath<strong>并没有指向要向其中输入数据的字段,实际上它指向的是列标题</strong>。这就是为什么你不能在里面输入数据。在</p>
<p>请尝试下面的xpath来<strong>在乘客详细信息的第一行中填写姓名和年龄</strong>:</p>
<ol>
<li>以下代码将在第一行填写<strong>乘客姓名</strong>:<br/></li>
</ol>
<pre>driver.find_element_by_xpath("(//tbody[@id='addPassengerForm:psdetail:tb']//input[contains(@id,'psgnName')])[1]").send_keys("ABC")</pre>
<ol start=“2”>
<li>以下代码将在第一行填写<strong>乘客年龄</strong>:<br/></li>
</ol>
^{pr2}$
<p>类似地,为了在下一行输入乘客姓名的数据,您只需将xpath的最后一部分从<strong><code>[1]</code>调整为<code>[2]</code></strong>。在</p>