【问题标题】:Trying to click on the Internal Tabs in the WebPage, but the code not working尝试单击网页中的内部选项卡,但代码不起作用
【发布时间】:2017-07-06 11:21:18
【问题描述】:

单击网页内的选项卡时,代码不起作用,甚至在执行代码时也没有出现任何错误。 我正在编写的代码单击选项卡 [Categorization]

WebElement tabCategory = driver.findElement(By.xpath("//dd[2]//a[@class='btn f1']"));
tabCategory.click()

<dd class="OuterTab" artabid="304287650" arwindowid="3" style="top: 1px; z-index: 1; left: 71px; visibility: inherit; display: block;"><span class="TabLeft">&nbsp;</span>
<span class="Tab"><a href="javascript:" class="btn f1" style="color:#000000;">Categorization</a>
</span>
<span class="TabRight">&nbsp;</span>
<span class="TabLeft">&nbsp;</span>
<span class="Tab"><a href="javascript:" class="btn f1" style="color:#000000;">Categorization</a>
</span>
<span class="TabRight">&nbsp;</span>
</dd>

我想点击的标签的图片如下所示

【问题讨论】:

    标签: java selenium automation css-selectors qa


    【解决方案1】:

    试试下面提到的xpath

    //a[text()= 'Categorization']/following::a
    

    //span[@class='TabRight']/..//preceding-sibling::a[text()= 'Categorization']/following::a 
    

    【讨论】:

    • 如果您的回答是helpful,请将此回答标记为Accepted
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    • 2014-08-31
    • 1970-01-01
    • 2021-09-21
    相关资源
    最近更新 更多