用没有多个发送键(循环)的文本填充所有文本区域?

我有一个问题,我有一个表单(angularJS),这个表单有 10 个 textarea,现在我有 10 次,sendkes 动作,这使得代码很难看:(


如何找到所有我的 textareas 并只传递一次值?


现在我有这样的事情:


 List<WebElement> allFormElements= driver.findElements(By.xpath("myPath"));

        allFormElements.size();

        System.out.println("Lets count all forms" +allFormElements);

        for (WebElement item : allFormElements) {

            if (item.getTagName().equals("textarea"))

           item.sendKeys("testing values");

        }


尚方宝剑之说
浏览 141回答 1
1回答

慕仙森

这个解决方案对我很有效!List<WebElement> allInputFields = driver.findElements(By.cssSelector("cm-edit-request-form dx-text-area textarea"));&nbsp; &nbsp; &nbsp; &nbsp; if(allInputFields.size()!=0){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(WebElement allInputFieldsElement:allInputFields){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(allInputFieldsElement.isEnabled()) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait.until(ExpectedConditions.elementToBeClickable((allInputFieldsElement)));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allInputFieldsElement.sendKeys("Automation text" + uuid);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java