-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProdusCeai.java
More file actions
87 lines (59 loc) · 2.16 KB
/
Copy pathProdusCeai.java
File metadata and controls
87 lines (59 loc) · 2.16 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package contentspeededgedriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.interactions.Actions;
import java.util.Iterator;
import java.util.Set;
public class ProdusCeai {
WebDriver driver;
By produsArmonia = By.xpath("//*[@id=\"product_addToCart\"]");
By finalizeazaComanda = By.xpath("//*[@id='popup-roo']/div[2]/div/a[3]");
By cosComanda = By.xpath("//*[@id=\"header\"]/div[2]/div/div[1]/div[4]/a/span");
public ProdusCeai(WebDriver driver) {
this.driver = driver;
}
void clickAdaugaCos() {
driver.findElement(produsArmonia).click();
}
void clickFinalizeaza() {
try {
String MainWindow = driver.getWindowHandle();
// To handle all new opened window.
Set<String> s1 = driver.getWindowHandles();
Iterator<String> i1 = s1.iterator();
while (i1.hasNext()) {
String ChildWindow = i1.next();
driver.switchTo().window(ChildWindow);
driver.findElement(By.partialLinkText("Finalizeaza comanda")).click();
}
} catch (WebDriverException ex) {
ex.printStackTrace();
//driver.quit();
}
}
void CosClick() {
//driver.findElement(cosComanda).click();
Actions actions = new Actions(driver);
actions.click(driver.findElement(cosComanda)).perform();
String MainWindow = driver.getWindowHandle();
Set<String> s1 = driver.getWindowHandles();
Iterator<String> i1 = s1.iterator();
//System.out.println(s1.size());
while (i1.hasNext()) {
String ChildWindow = i1.next();
driver.switchTo().window(ChildWindow);
driver.findElement(By.partialLinkText("Vezi cosul")).click();
}
}
void Actions() {
clickAdaugaCos();
clickFinalizeaza();
CosClick();
}
}