如何使用 Python selenium 驱动程序 select Microsoft CRM 表单中名称为 <input id = "lastname_i"...> 的姓氏元素?

How do I select the Last Name element on Microsoft CRM form that has the name <input id = "lastname_i"...> using Python selenium driver?

我不知道为什么我的 CRM 驱动程序没有在 HTML 元素下面捕捉到这个。我尝试过使用绝对和相对 XPath,尝试过使用 webdriver.get_element_by_id('lastname_i')get_element_by_css_selector('input.lastname_i') 以及更多脚本可能性。无论出于何种原因,webdriver 都找不到此元素。

谁能帮我写出正确的 Python 脚本?我认为这与我要查找的 HTML 元素中没有 /> 这一事实有关。

<div class="ms-crm-Inline-Edit  ms-crm-Inline-HasError"><input id="lastname_i" attrname="lastname" attrpriv="create, read, update" maxlength="50" title="" class="ms-crm-InlineInput" controlmode="alwaysedit" style="ime-mode: active;" aria-invalid="true" type="text"></div>

等待 20 秒,然后尝试下面的代码。

webdriver.get_element_by_xpath("//input[@id='lastname_i']")