Search code examples
pythonhtmlselenium-webdriverdynamics-crmelement

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


I have no clue why my CRM driver is not catching this below HTML element. I have tried using absolute and relative XPath, tried using webdriver.get_element_by_id('lastname_i'), get_element_by_css_selector('input.lastname_i'), and many more scripting possibilities. For whatever reason, the webdriver does not find this element.

Can anyone help me with the correct Python script? I think it has something to do with the fact there is no /> in the HTML element I am trying to find.

<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>

Solution

  • Wait for 20 seconds and try this below code.

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