错误: - 对于WebElement类型,未定义方法selectByVisibeText(String)

问题描述 投票:0回答:1

我是SELENIUM的新手,我在最后一行得到了错误。你能告诉我解决方案和这个问题的原因吗?错误: - “类型WebElement未定义方法selectByVisibeText(String)”

package kemgo_package;
import java.util.concurrent.TimeUnit;
import org.apache.bcel.generic.Select;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class kengo_class 
{

public static void main(String[] args)
{
    System.setProperty("webdriver.gecko.driver","E:\\geckodriver-v0.19.1-win64\\geckodriver.exe");
    System.out.println("Hello");
    WebDriver driver= new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.get("http://kemgov2.cladev.com");   
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    System.out.println("hello world-----2");
    driver.findElement(By.name("login")).click();
    driver.findElement(By.xpath("html/body/div[1]/div/header/div[2]/nav/div/ul[2]/li[3]/a")).click();
    driver.findElement(By.id("userClearBtn")).click();

    driver.findElement(By.xpath("/html/body/div[1]/div/div/div/section/div/form/div[1]/div[2]/div[2]/div[1]/div/div/a/span[1]")). selectByVisibeText("Test_Product01");    // Error:-  "The method selectByVisibeText(String) is undefined for the type WebElement"



}
}
selenium selenium-webdriver
1个回答
1
投票

这是你的错误:

driver.findElement(By.xpath("/html/body/div[1]/div/div/div/section/div/form/div[1]/div[2]/div[2]/div[1]/div/div/a/span[1]")). selectByVisibeText("Test_Product01");    // Error:-  "The method selectBy**Visibe**Text(String) is undefined for the type WebElement"

它的拼写是“可见的”,在“b”和“e”之间有一个小写的“L”。

© www.soinside.com 2019 - 2024. All rights reserved.