单击Selenium Webdriver Java的选项卡定位器

时间:2018-11-16 17:47:47

标签: selenium selenium-webdriver

登录页面后,我找不到用于单击选项卡的正确定位器

HTML:

<td title="Maintenance" id="c1_tab3" class="tabTab noselect tabSelectedTab" onclick="getcontrol( 'c1').setvalue(3);">Maintenance</td>

测试:

@Test
public void Case1() {
    driver.navigate().to(URL);
    //driver.findElement(By.linkText("Transcode Service")).click();
    driver.findElement(By.id("c1_tab3")).click();

错误:

  

FAILED: Case1 org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"c1_tab3"} (Session info: chrome=70.0.3538.102)

1 个答案:

答案 0 :(得分:0)

您可以尝试以下xpath:

driver.findElement(By.xpath("//td[@id='c1_tab3' and contains(.,'Maintenance')]")).click();