Alichino Alichino - 5 months ago 22
AngularJS Question

Unable to locate element (text-field) in Angular JS using selenium in Python

I'm having a problem sending keys to a text field on an webpage written in angular JS.

Here is the WebElement in question:

<input name="CreateUserForename" id="Textc3829619-ad42-4df7-bbe3-5bdbe9fb9bce"
ng-class="{'ng-pristine': controller.$pristine, 'ng-invalid': controller.$invalid,
'ng-invalid-required': controller.$error.required, 'ng-valid': controller.$valid,
'ng-dirty': controller.$dirty}" class="form-input ng-scope ng-valid ng-dirty" type="text"
ng-if="!multiline" ng-hide="disabled" maxlength="">


Just using
driver.find_element_by_xpath({xpath}).send_keys({keys})
gives this error:

Message: no such element: Unable to locate element:
{"method":"xpath","selector":"//*[@id="Text9c04f240-66a6-478b-92c2-13bb39379b8e"]"}


Same when using the css_selector.

One workaround I've found is using ActionChains and
move_to_element_with_offset
, but that is not ideal.

Any ideas?

(please don't suggest the Protractor)

Answer

OK, it seems that driver.find_element_by_name("CreateUserForename") does the trick.

Comments