-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser_switch.java
More file actions
58 lines (48 loc) · 1.96 KB
/
browser_switch.java
File metadata and controls
58 lines (48 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Actions;
public class cross_browser {
public static void main(String[] args) {
String browser = "chrome";
if (browser.equals("chrome")) {
System.setProperty("webdriver.chrome.driver", "C://Users//admin//workspace//Auto/chromedriver.exe");
WebDriver driver1 = new ChromeDriver();
driver1.manage().window().maximize();
driver1.get("https://demoqa.com/droppable/");
WebElement from = driver1.findElement(By.id("draggable"));
WebElement to = driver1.findElement(By.id("droppable"));
Actions act = new Actions(driver1);
act.dragAndDrop(from, to).perform();
driver1.quit();
}
else if (browser.equals("firefox")) {
System.setProperty("webdriver.gecko.driver", "C://Users//admin//workspace//Auto/geckodriver.exe");
WebDriver driver2 = new FirefoxDriver();
driver2.manage().window().maximize();
driver2.get("https://demoqa.com/droppable/");
WebElement from1 = driver2.findElement(By.id("draggable"));
WebElement to1 = driver2.findElement(By.id("droppable"));
Actions act1 = new Actions(driver2);
act1.dragAndDrop(from1, to1).perform();
driver2.quit();
}
else if (browser.equals("IE")) {
System.setProperty("webdriver.ie.driver", "C://Users//admin//workspace//Auto//IEDriverServer.exe");
WebDriver driver3 = new InternetExplorerDriver();
driver3.manage().window().maximize();
driver3.get("https://demoqa.com/droppable/");
WebElement from2 = driver3.findElement(By.id("draggable"));
WebElement to2 = driver3.findElement(By.id("droppable"));
Actions act2 = new Actions(driver3);
act2.dragAndDrop(from2, to2).perform();
driver3.quit();
} else {
System.out.println("kuch nahi");
}
}
}