擅长:python、mysql、java
<p>您可以使用<code>driver.find_element_by_xpath()</code>选择适当的<code>td</code>标记。应该使用的<code>XPath</code>表达式如下:</p>
<pre><code>`'//label[@for="Rooms"]/parent::td/following-sibling::td'`
</code></pre>
<p>这将选择属性等于<code>Rooms</code>的<code>for</code>标记,然后导航到其父元素<code>td</code>,然后导航到以下元素<code>td</code>。</p>
<p>所以你的密码是:</p>
<pre><code>elem = driver.find_element_by_xpath(
'//label[@for="Rooms"]/parent::td/following-sibling::td')
</code></pre>
<p>XPath表达式的一个实际例子是<strong><a href="http://xpathfiddle.net/9IPJCI" rel="nofollow">here</a></strong>。</p>