
尝试让脚本选择顶部的filter按钮,但似乎不知道如何输入XPath。我相信这与它在一个单独的iframe中有关。
package chromebrowser;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class JavaClass {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Newfolder\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://mlvtwrew73.consilio.com/Relativity/");
driver.manage().window().maximize();
//Thread.sleep(5000); this can be used as a wait command before moving on to the next function
WebElement objWE;
Thread.sleep(9000);
// objWE = driver.findElement(By.linkText("User Status"));
// objWE.click();
driver.switchTo().defaultContent();
driver.findElement(By.xpath("id(\"ctl00_ctl00_itemList_FilterSwitch\")")).click();
// objWE = driver.findElement(By.id("1"));
// driver.close(); will be used to close the site once all testing completes
}
}
发布于 2017-11-07 03:02:47
使用ID定位器--它在这里更合适(而且比XPath更快):
WebDriverWait wait= new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.elementToBeClickable(By.id("ctl00_ctl00_itemList_FilterSwitch")));
driver.findElement(By.id("ctl00_ctl00_itemList_FilterSwitch")).click();发布于 2017-11-07 02:28:46
关于你的问题,我需要更多的澄清。据我所知,我认为你需要一个滤镜图像的XPath的要求。如果我是对的,试试这个:
//div[@class='actionCellContainer']//a/img[@class='itemListActionImage']发布于 2017-11-07 02:49:23
看起来你传入的XPath不正确。试试这个:
driver.findElement(By.xpath("//a[@id='ctl00_ctl00_itemList_FilterSwitch']")).click();https://stackoverflow.com/questions/47143280
复制相似问题