Reputation: 150
I need to tick the Add GPUs check box. WebSite https://cloud.google.com/products/calculator There is a code
WebElement checkAddGRU = new WebDriverWait(driver, 20)
.until(ExpectedConditions.
presenceOfElementLocated(By.xpath("//md-input-container/md-checkbox/div[contains(text(),'Add GPUs')]")));
WebElement numberOfGPU = new WebDriverWait(driver, 10)
.until(ExpectedConditions.elementToBeClickable(By.xpath("//md-select[@placeholder='Number of GPUs']")));
while (!numberOfGPU.isDisplayed()) {
checkAddGRU.click();
}
But it don't work. The checkbox leasted empty.
Upvotes: 1
Views: 70
Reputation: 14135
The reason you are not able to select the checkbox is due to the presence of the checkbox in an iframe. Try switching to iframe first and then select the checkbox.
WebElement iframe = driver.findElement(By.cssSelector("#myFrame"));
driver.switchTo().frame(iframe);
driver.findElement(By.xpath("//md-input-container/md-checkbox/div[contains(text(),'Add GPUs')]").click()
Upvotes: 1