Reputation: 945
HTML code
<textarea type="text" name="pos_description" rows="4" class="form-control ng-pristine ng-invalid ng-invalid-required ng-valid-minlength ng-valid-maxlength ng-touched" id="pos_description" placeholder="Enter Description" ng-model="data.description" minlength="150" maxlength="5000" required="">
</textarea>
My code
browser.executeScript('window.scrollTo(0,250);');
browser.sleep(3000);
element(by.model('textarea.data.description')).sendKeys("values");
I am getting the error as below:-
StaleElementReferenceError: stale element reference: element is not attached to the page do
cument
(Session info: chrome=43.0.2357.132) (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Linux 3.13.0-55-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 45 milliseconds
Please help me
Upvotes: 2
Views: 811
Reputation: 1
Your html looks like this: ng-model="data.description" but you're doing this: element(by.model('textarea.data.description'))
It should be: element(by.model('data.description'))
Upvotes: 0
Reputation: 3776
This could be mostly because of the page not loaded properly. The Page might have loaded but some Elements in the page might load, disappear out of the page for a fraction of second and then load again. So when the page is loaded, the text area is found by Selenium and by the time it tries to click, the Element might have reloaded.
Put a try catch [Java] equivalent in protractor to catch the Exception and find the element again and click for the second time.
try {
element(by.model('textarea.data.description')).sendKeys("values");
} catch (StaleElementReferenceError e) {
element(by.model('textarea.data.description')).sendKeys("values");
}
I dont know of this is possible in Protractor. If not you can always increase the sleep time.
Upvotes: 1