我可以点击网站上的过滤器选项,我的问题是“使用 xpath 打开过滤器选项,然后过滤器选项将被关闭”
I am able to click on filter option on website,my question is " filter option was opened by using xpath and at a time filter option will be closed"
我可以点击网站上的过滤器选项,我的问题是“使用 xpath 打开过滤器选项,然后过滤器选项将被关闭”
代码试验:
WebElement element= driver.findElement(By.xpath("//button[contains(@class,'slds-button slds-button--icon-border-filled action-control__button action-control--square')]"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
到click()
你需要归纳的元素 for the elementToBeClickable()
and you can use either of the following :
cssSelector
:
((JavascriptExecutor) driver).executeScript("arguments[0].click();", new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.slds-button.slds-button--icon-border-filled.action-control__button.action-control--square"))));
xpath
:
((JavascriptExecutor) driver).executeScript("arguments[0].click();", new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='slds-button slds-button--icon-border-filled action-control__button action-control--square']"))));
我可以点击网站上的过滤器选项,我的问题是“使用 xpath 打开过滤器选项,然后过滤器选项将被关闭”
代码试验:
WebElement element= driver.findElement(By.xpath("//button[contains(@class,'slds-button slds-button--icon-border-filled action-control__button action-control--square')]"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
到click()
你需要归纳的元素elementToBeClickable()
and you can use either of the following
cssSelector
:((JavascriptExecutor) driver).executeScript("arguments[0].click();", new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.slds-button.slds-button--icon-border-filled.action-control__button.action-control--square"))));
xpath
:((JavascriptExecutor) driver).executeScript("arguments[0].click();", new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='slds-button slds-button--icon-border-filled action-control__button action-control--square']"))));