为了账号安全,请及时绑定邮箱和手机立即绑定

尝试通过 Selenium 清除文本时出现 InvalidElementStateException

尝试通过 Selenium 清除文本时出现 InvalidElementStateException

C#
吃鸡游戏 2021-06-28 13:58:38
我正在测试的 Web 应用程序在删除记录时需要确认。我创建了一个测试来输入删除此记录的有效理由。执行此操作的代码如下:DeleteFieldButton.            Click();        WaitMethods.WaitForElementToBeDisplayed(RemovalReason, 20);        RemovalReason            .Click();        RemovalReason            .Clear();        RemovalReason            .SendKeys("Automated Test - Delete Field");文本框的XPath如下:private Label RemovalReason = new Label(By.XPath("//*[@placeholder = 'Removal reason']"));无论何时运行测试,都会返回以下异常。OpenQA.Selenium.InvalidElementStateExceptionHResult=0x80131500Message=Cannot clear By.XPath: //*[@placeholder = 'Removal reason'] as it is not declared as a writable text elementSource=webStackTrace:at web.Elements.Common.Element.Clear()at Daera.Efs.Test.E2e.PageObjects.ApplicationSummary.DeleteField(String FieldIDToDelete) in C:\Code\Local\WebApp.E2e\PageObjects\ApplicationSummary.cs:line 280 at Test.E2e.Tests.ApplicationSummaryTest.Delete_Wider_General_Field_From_Application_Summary() in C:\Code\Local\WebApp.E2e\Tests\ApplicationSummaryTest.cs:line 45以下是 Web 应用程序中元素的 HTML:<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="">
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 537 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信