简体   繁体   English

Selenium:Java中的cssSelector的UnexpectedTagNameException

[英]Selenium: UnexpectedTagNameException for cssSelector in Java

I am getting UnexpectedTagNameException for cssSelector . 我得到cssSelector UnexpectedTagNameException Below is the piece of code for HTML and java 以下是HTML和Java的代码段

<table cellspacing="0" cellpadding="0" border="0" class="puMB">
    <tbody><tr><td valign="center">
    <div class="popupMenuButton">  
    <a id="_a9sizb" bh="PML" _mid="_op49pd" class="awmenuLink" style="text-decoration:none" href="#">
    <nobr>
    lucky
    <img width="15" height="17" align="absmiddle" border="0" style="margin-bottom:1px;" src="/EasyCare-2.0/AribaWeb/ad/content/AWXDebugResourceActions/13/en_US/widg/arrowcolor.gif" alt=""></nobr></a></div></td></tr></tbody></table>

 driverWait = new WebDriverWait(driver, 1000);
    public WebElement waitByCSSSelector(String locator) {
            return driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(locator)));
        }
      WebElement dropDownListBox1 = waitById("_a9sizb");
            Select clickThis1 = new Select(dropDownListBox1);
            clickThis1.selectByIndex(5);
            waitByCSSSelector("//*[@id='_a9sizb']").click();

    Exception in thread "main" org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "a"
    Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
    System info: host: 'Sudhir', ip: '192.168.250.16', os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_51'
    Driver info: driver.version: unknown
        at org.openqa.selenium.support.ui.Select.<init>(Select.java:46)
        at ui.UIRegisterPatient.setCharityAmount(UIRegisterPatient.java:151)
        at tc.TCRegistrationNewEmerPatient.setCharityAmountForEmer(TCRegistrationNewEmerPatient.java:129)
        at tc.TCRegistrationNewEmerPatient.setNewPrimayPatientDetails(TCRegistrationNewEmerPatient.java:32)
        at tc.StartAutmation.main(StartAutmation.java:17) 

When I try to use the following code 当我尝试使用以下代码时

waitByCSSSelector("#_a9sizb > nobr > img").click();

There is no response from the application. 应用程序没有响应。

Any help is highly appreciable. 任何帮助都是非常明显的。 Apologies if this has already been discussed. 抱歉,如果已经讨论过。

The error is within this string: Select clickThis1 = new Select(dropDownListBox1); 错误在此字符串内: Select clickThis1 = new Select(dropDownListBox1);

"Select" type should be select, but not a link as you giving it <a id="_a9sizb... . As we see from documentation: 正如您从文档中看到的那样,应该选择“选择”类型,但不要选择链接<a id="_a9sizb...

Class Select 班级选择

Models a SELECT tag, providing helper methods to select and deselect options. 为SELECT标记建模,提供帮助方法来选择和取消选择选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Selenium(Java)中通过cssSelector获取元素 - Get element by cssSelector in Selenium (Java) Selenium:在 Java 中使用 cssSelector 提取 div 的文本 - Selenium: Extract Text of a div with cssSelector in Java 通过cssSelector在JAVA(Selenium)中进行findElement的循环 - For loop in JAVA (Selenium) for findElement through cssSelector 通过 Selenium 和 Java 使用 CssSelector 识别新添加的元素 - Identifying the newly added element using CssSelector through Selenium and Java Selenium Web驱动程序不从Java中的cssSelector返回值 - selenium web driver does not return the value from cssSelector in java &#39;UnexpectedTagNameException&#39; 和 Element 应该是“select”,但是通过 Selenium java 使用“Select”函数是“div”错误 - 'UnexpectedTagNameException' and Element should have been "select" but was "div" error using 'Select' function through Selenium java Selenium Java-错误-org.openqa.selenium.support.ui.UnexpectedTagNameException:元素应为“选择”但为“输入” - Selenium Java - Error- org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been “select” but was “input” 硒:通过CssSelector确定WebElement的状态 - Selenium: Determine status of WebElement by CssSelector Selenium cssSelector可在IDE中工作,但不能在Webdriver中工作 - Selenium cssSelector works in IDE but not in Webdriver 无法使用Selenium WebDriver Java通过Xpath / classname / cssSelector查找gif图像 - Unable to find gif image by Xpath/classname/cssSelector using selenium webdriver java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM