ti.ide.MainPageTestError Maven / Gradle / Ivy
// Generated by Selenium IDE
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;
public class MainPageTest {
private WebDriver driver;
private Map vars;
JavascriptExecutor js;
@Before
public void setUp() {
driver = new FirefoxDriver();
js = (JavascriptExecutor) driver;
vars = new HashMap();
}
@After
public void tearDown() {
driver.quit();
}
public String waitForWindow(int timeout) {
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
e.printStackTrace();
}
Set whNow = driver.getWindowHandles();
Set whThen = (Set) vars.get("window_handles");
if (whNow.size() > whThen.size()) {
whNow.removeAll(whThen);
}
return whNow.iterator().next();
}
public void frame() {
driver.get("http://localhost:55555/testIFrame.html");
driver.manage().window().setSize(new Dimension(934, 603));
driver.findElement(By.id("buttonIFrame")).click();
driver.findElement(By.id("selectIFrame")).click();
driver.findElement(By.cssSelector("option")).click();
}
@Test
public void mainPage() {
vars.put("toto", "coucou");
System.out.println(vars.get("foo"));
driver.get("http://localhost:55555/testWithoutFixedPattern.html");
driver.manage().window().setSize(new Dimension(934, 603));
driver.findElement(By.id("image")).click();
assertThat(driver.findElement(By.id("link")).getText(), is("My link"));
vars.put("window_handles", driver.getWindowHandles())
//Ligne en erreur juste au dessus
driver.findElement(By.id("link")).click();
vars.put("win841", waitForWindow(2000));
driver.switchTo().window(vars.get("win841").toString());
driver.findElement(By.id("buttonIFrame")).click();
frame();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy