Burada 3 tarayıcıda aynı testi koşturuyoruz. open methodunu tanımlıyoruz. Tarayıcıların driver larının yerlerini gösteriyoruz. Sonra test kısmında sırayla çağırıyoruz. IE'de hata alıyorsanız selenium ile sürümlerinin birbirleriyle uyumlu olduklarından emin olun.
public class CrossBrowserTest {
WebDriver driver;
public void open()
{
driver.get("https://www.google.com/");
String Title = driver.getTitle();
System.out.println("Title of the webpage = " +Title);
assertEquals(Title,"Google");
}
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.gecko.driver","C:\\Selenium\\geckodriver-v0.23.0-win64\\geckodriver.exe");
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver_win32\\chromedriver.exe");
System.setProperty("webdriver.ie.driver","C:\\Selenium\\IEDriverServer_x64_3.14.0\\IEDriverServer.exe");
}
@Test
public void test() throws Exception {
for (int i=0; i<3; i++){
if (i==0)
{
driver = new FirefoxDriver();
open();
}
else if (i==1)
{
driver = new ChromeDriver();
open();
}
else if (i==2)
{
driver = new InternetExplorerDriver();
open();
}
}
}
@After
public void tearDown() throws Exception {
driver.quit();
}
}
public class CrossBrowserTest {
WebDriver driver;
public void open()
{
driver.get("https://www.google.com/");
String Title = driver.getTitle();
System.out.println("Title of the webpage = " +Title);
assertEquals(Title,"Google");
}
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.gecko.driver","C:\\Selenium\\geckodriver-v0.23.0-win64\\geckodriver.exe");
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver_win32\\chromedriver.exe");
System.setProperty("webdriver.ie.driver","C:\\Selenium\\IEDriverServer_x64_3.14.0\\IEDriverServer.exe");
}
@Test
public void test() throws Exception {
for (int i=0; i<3; i++){
if (i==0)
{
driver = new FirefoxDriver();
open();
}
else if (i==1)
{
driver = new ChromeDriver();
open();
}
else if (i==2)
{
driver = new InternetExplorerDriver();
open();
}
}
}
@After
public void tearDown() throws Exception {
driver.quit();
}
}
Yorumlar
Yorum Gönder