java - 编译时显示的错误消息“未定义类型 RelativeLocators 的方法 withTagName(String)”
问题描述
在编译时,我在 Eclipse 中运行以下程序时收到错误“对于类型 RelativeLocators 的方法 withTagName(String) 未定义”,即使 selenium 版本是“selenium-java-4.0.0-beta-4”和另一个第 5 条导入语句显示错误“无法解析导入 org.openqa.selenium.support.locators.RelativeLocator.withTagName”
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import static org.openqa.selenium.support.locators.RelativeLocator.withTagName;
public class RelativeLocators {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("rahulshettyacadmy.com/angularpractice");
WebElement editbox = driver.findElement(By.cssSelector("[name='name']"));
driver.findElement(withTagName("input").above(editbox).getText());
WebElement dobleabel = driver.findElement(By.cssSelector("[for='dateofbirth']"));
driver.findElement(withTagName("input").below(dobleabel)).sendKeys("02/02/1993");
WebElement iceCreams = driver.findElement(By.xpath("//label[text()='Check me out if you Love IceCreams!']"));
driver.findElement(withTagName("input").toLeftOf(iceCreams)).click();
WebElement radiobutton = driver.findElement(By.id("inlineRadio1']"));
System.out.println(driver.findElement(withTagName("input").toRightOf(radiobutton)).getText());
}
}
解决方案
您在 Selenium 插件中有 getTagName 方法,但没有 withTagName ...
推荐阅读
- rest - 具有两条路径的 cookie 的 API 设计
- r - 如何在安装之前或之后修改 R 库源代码的特定脚本?
- google-apps-script - 谷歌脚本同一行中的多个条件和前一行中的值的验证
- java - 如何使用事务 java 引发错误
- r - “包含”功能
- google-cloud-platform - 在 Google Cloud Platform 上的 URL 中隐藏“/index.html”
- php - php-fpm 和 dns 随机无法正常工作
- magento - 更改 Magento 2.2.4 的主题时出现错误“区域已设置”
- haskell - 找不到模块“Criterion.Main”
- xamarin - Xamarin Forms ToolbarItems 显示在错误的页面上