在Firefox中使用Selenium WebDriver更改选项卡

时间:2017-04-21 08:05:10

标签: selenium firefox xpath

我在网站上有li标签,我无法更改标签,已经尝试使用xpath,目前看起来像这样:

Select objSelect = new Select(objdriver.findElement(By.xpath("//*[@id='navigation']/li[2]/a")));
WebElement navigation = objdriver.findElement(By.xpath("//*[@id='navigation']/li[2]/a"));

HTML代码:

<div>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div>
<div class="pull-right padding-top">
<a href="http://www.mineotaur.org>">
</div>
<ul id="navigation" class="nav navbar-nav">
<li class="active">
<a data-toggle="tab" href="#genewise">Gene-wise scatterplot</a>
</li>
<li>
<a data-toggle="tab" href="#groupwiseDistributionForm">Gene-wise distribution</a>
</li>
<li>
<a data-toggle="tab" href="#cellwise">Cell-wise scatterplot</a>
</li>
<li>
<a data-toggle="tab" href="#cellwiseDistribution">Cell-wise distribution</a>
</li>
<li id="toolNav" class="disabled">
<a data-toggle="tab" href="#tools">Tools</a>
</li>

感谢您的回答!

1 个答案:

答案 0 :(得分:0)

您可能需要使用此方法来传递驱动程序,但这是我使用的

openTabElement.click();
ArrayList<String> tabs = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs2.get(1));
driver.close();
driver.switchTo().window(tabs2.get(0));