【问题标题】:findAttribute("value") returns null in firefoxfindAttribute("value") 在 Firefox 中返回 null
【发布时间】:2017-08-12 11:32:03
【问题描述】:

元素 .getAttribute("value") 在 chrome 中工作正常并返回值,但我尝试在 firefox 中使用相同的方法及其返回“null”值

<textarea id="xyz" class="span12 ng-pristine ng-untouched ng-invalid ng-invalid-required ng-valid-maxlength" name="otherDescription" data-ng-model="other.description" data-ng-required="true" placeholder="Enter trip details" type="text" maxlength="10000" required="required"/>

【问题讨论】:

  • 你在用火狐驱动吗?
  • 分享 HTML 以及您尝试过的代码。
  • .getFirstTripDetaisInput() .getAttribute("value") .contains(xyz));

标签: java google-chrome selenium firefox automation


【解决方案1】:

检查您的输入标签是否在 firefox 中具有 value 属性,否则尝试使用 gettext() 有时此模式会因浏览器而异。

如果上面的选项不起作用,你可以去下面

JavascriptExecutor jse = (JavascriptExecutor)驱动程序; WebElement element = driver.findElement(By.xpath("//span[@itemprop='telephone']")); jse.executeScript("返回参数[0].innerhtml", element);

【讨论】:

  • 在我的断言中,我正在验证我输入的值,输入包含相同的值,使用 javascript 我该如何验证?
  • 将文本复制到下面复制的字符串中,并将其输入到您的断言 WebElement currentTimeElement=driver.findElement(By.xpath("//span[@class='ytp-time-current'] ")); String content=(String)((JavascriptExecutor)driver).executeScript("return arguments[0].innerHTML", currentTimeElement);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-11
  • 2023-03-18
  • 1970-01-01
相关资源
最近更新 更多