我正在尝试选择一个文本框并通过 selenium Web 驱动程序在其中输入文本。html如下:
</div><div>
<input name="mLayout$ctl00$ctl00$6$16$ctl00$Database" type="text" value="Enter database name" maxlength="175" size="26" id="mLayout_ctl00_ctl00_6_16_ctl00_Database" accesskey="s" title="Go search this database" class="InputContent GhostText" onfocus="SearchBoxOnFocus('mLayout_ctl00_ctl00_6_16_ctl00_Database');" onkeypress="if(!__TextBoxOnKeyPress('mLayout$ctl00$ctl00$6$16$ctl00$GoButton',event.which)) { return false; }" /> <input type="image" name="mLayout$ctl00$ctl00$6$16$ctl00$GoButton" id="mLayout_ctl00_ctl00_6_16_ctl00_GoButton" title="Go search database" src="http://images-statcont.westlaw.com/images/go_v602.gif" alt="Go search database" align="absmiddle" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("mLayout$ctl00$ctl00$6$16$ctl00$GoButton", "", true, "", "", false, false))" style="height:18px;width:21px;border-width:0px;" />
</div><div>
我试过以下
driver.find_element_by_id("mLayout_ctl00_ctl00_6_16_ctl00_Database")
driver.find_element_by_name("mLayout$ctl00$ctl00$6$16$ctl00$Database")
dbElement = WebDriverWait(driver, 20).until(lambda x : x.find_element_by_id("mLayout_ctl00_ctl00_6_16_ctl00_Database"))
$ 和 _ 字符有什么特别之处吗?为什么硒不能定位这些元素?