The web application I am testing requires confirmation when deleting a record.
I have created a test to enter in a valid reason for deleting this record.
The code to do this is as follows:
DeleteFieldButton.
Click();
WaitMethods.WaitForElementToBeDisplayed(RemovalReason, 20);
RemovalReason
.Click();
RemovalReason
.Clear();
RemovalReason
.SendKeys("Automated Test - Delete Field");
The XPath to the text box is as follows:
private Label RemovalReason = new Label(By.XPath("//*[@placeholder = 'Removal reason']"));
Whenever the test is run the following exception is returned.
OpenQA.Selenium.InvalidElementStateException
HResult=0x80131500
Message=Cannot clear By.XPath: //*[@placeholder = 'Removal reason'] as it is
not declared as a writable text element
Source=web
StackTrace:
at web.Elements.Common.Element.Clear()
at Daera.Efs.Test.E2e.PageObjects.ApplicationSummary.DeleteField(String
FieldIDToDelete) in
C:CodeLocalWebApp.E2ePageObjectsApplicationSummary.cs:line 280
at Test.E2e.Tests.ApplicationSummaryTest.Delete_Wider_General_Field_From_Application_Summary() in C:CodeLocalWebApp.E2eTestsApplicationSummaryTest.cs:line 45
Below is the HTML of the element on the web application:
<input ng-keypress="dialog.keypress($event)" md-autofocus="" ng-model="dialog.result" placeholder="Removal reason" class="ng-valid md-input ng-not-empty md-autofocus ng-touched ng-dirty ng-valid-parse" aria-label="Removal reason" id="input_22" aria-invalid="false" style="">
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…