iframe点击在Chrome中不起作用

时间:2018-06-21 14:39:06

标签: java selenium selenium-webdriver

img1 == None

我已经能够切换到iframe,然后单击图像选择[如图1所示],然后无法单击div预览按钮[如图2所示-蓝色按钮],即“应用并关闭” 。

使用““ driver.findElement(By.xpath(” // iframe [@ class = contains(text(),'Apply&close)]“)))。click();”或使用Id或CSS选择器

Image 1 Image 2

有什么想法吗?

public void nmb_message() throws IOException, InterruptedException {

    WebDriver driver = Driverfactory.open("chrome", ".com");
    Logins login = new Logins();
    login.campaignqa();
    String actualTitle = driver.getTitle();
    String expectedTitle = "SmartFocus";


    (new Actions(driver)).dragAndDrop(element2, target2).perform();
    WebElement myDynamicElement2 = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.presenceOfElementLocated(By.xpath( "//*[contains(text(), 'Add a picture')]")));
    myDynamicElement2.click();
    Thread.sleep(3000);
    driver.switchTo().frame(driver.findElement(By.cssSelector("#msg-editor-imagelib-iframe")));
    Thread.sleep(5000); 
    driver.findElement(By.xpath(".//*[@id='item-39571']/div/div[2]")).click(); Thread.sleep(15000L); driver.findElement(By.xpath( "//iframe[@class=contains(text(), 'Apply & close)]")).click(); }}

1 个答案:

答案 0 :(得分:0)

尝试使用此Xpath进行应用并关闭

.//*[@id='image-popup-options-apply']