Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
851 B
2
Indexable
Never
 @Test
    public void TC05_Only_2_Windowns() throws InterruptedException {
        driver.get("https://automationfc.github.io/basic-form/index.html");
        String parentWindowsID = driver.getWindowHandle();
        driver.findElement(By.xpath("//a[text()='GOOGLE']")).click();
        Thread.sleep(3000);
        switchToWindowsID(parentWindowsID);
        Assert.assertTrue(driver.findElement(By.xpath("//img[@id='hplogo']")).isDisplayed());//line này bị lỗi ko tìm thấy element 

    }

    public void switchToWindowsID(String parentID) {
               Set<String> allWindowsID = driver.getWindowHandles();
        for (String windowsID : allWindowsID)
        {
            if (!windowsID.equals(parentID)) {
                driver.switchTo().window(windowsID);
                break;
            }
        }
    }