-
Notifications
You must be signed in to change notification settings - Fork 0
/
AzurePractice.java
165 lines (95 loc) · 5.08 KB
/
AzurePractice.java
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package SeleniumCodePractice;
import java.io.File;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.Select;
public class AzurePractice {
public static void main(String[] args) throws InterruptedException {
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
System.setProperty("webdriver.chrome.driver", "./DriversNew/chromedriver.exe");
ChromeDriver driver = new ChromeDriver(options);
driver.get("https://azure.microsoft.com/en-in");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
// Click on pricing
driver.findElementByLinkText("Pricing").click();
// Click on Pricing calculator
driver.findElementByLinkText("Pricing calculator").click();
// Click on Containers
driver.findElementByXPath("//button[text()='Containers']").click();
// Click on Container Instances
driver.findElementByXPath("(//span[@class='sd-truncateText'])[56]").click();
Thread.sleep(1000);
// Click on Container Instance Added view
driver.findElementByXPath("//a[text()='View']").click();
// Select Region as South India
WebElement findElementByXPath = driver.findElementByXPath("//select[@name='region']");
Select select = new Select(findElementByXPath);
select.selectByVisibleText("South India");
// Set the Duration as 180000 seconds
driver.findElementByXPath("(//div[@class='wa-textNumber'])[2]//input").clear();
Thread.sleep(1000);
driver.findElementByXPath("(//div[@class='wa-textNumber'])[2]//input").sendKeys("180000");
// Select the memory as 4 GB
WebElement findElementByXPath2 = driver.findElementByXPath("(//div[@class='calculator-dropdown '])[3]//select");
Select selectMemory = new Select(findElementByXPath2);
selectMemory.selectByVisibleText("4 GB");
Thread.sleep(1000);
// Enable Show Dev/test Pricing
driver.findElementByXPath("//button[@id='devtest-toggler']").click();
// Select the currency
WebElement findElementByXPath3 = driver.findElementByXPath("//select[@class='select currency-dropdown']");
Select selectCurrency = new Select(findElementByXPath3);
selectCurrency.selectByValue("INR");
// Print the Estimated Monthly Cost
String getEstMonCost = driver.findElementByXPath("(//span[@class='numeric'])[6]").getText();
System.out.println("Estimated Monthly Cost is:" + getEstMonCost);
// Click on Export button
driver.findElementByXPath("//button[@class='calculator-button button-transparent export-button']").click();
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
// Check the file in local folder
chromePrefs.put("plugins.always_open_pdf_externally", true);
chromePrefs.put("download.default_directory", "C:\\Users\\MohanNiru\\Downloads");
ChromeOptions options2 = new ChromeOptions();
options2.setExperimentalOption("prefs", chromePrefs);
File file = new File("C:\\\\Users\\\\MohanNiru\\\\Downloads\\ExportedEstimate.xlsx");
if (file.exists()) {
System.out.println("File exist for container instance in the specified path");
}
// Click on Example Scenarios
Thread.sleep(3000);
WebElement findElementByLinkText = driver.findElementByLinkText("Example Scenarios");
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", findElementByLinkText);
// Click on CI/CD for containers
WebElement findElementByXPath4 = driver.findElementByXPath("//button[@title='CI/CD for Containers']");
executor.executeScript("arguments[0].click();", findElementByXPath4);
// Click on Add to Estimate
WebElement findElementByXPath5 = driver.findElementByXPath("//button[text()='Add to estimate']");
executor.executeScript("arguments[0].click();", findElementByXPath5);
selectCurrency.selectByValue("INR");
// Enable Show Dev/test Pricing
WebElement findElementByXPath6 = driver.findElementByXPath("//button[@id='devtest-toggler']");
executor.executeScript("arguments[0].click();", findElementByXPath6);
// Click on Export button
Thread.sleep(3000);
WebElement findElementByXPath7 = driver
.findElementByXPath("//button[@class='calculator-button button-transparent export-button']");
executor.executeScript("arguments[0].click();", findElementByXPath7);
Thread.sleep(2000);
chromePrefs.put("plugins.always_open_pdf_externally", true);
chromePrefs.put("download.default_directory", "C:\\Users\\MohanNiru\\Downloads");
ChromeOptions options3 = new ChromeOptions();
options3.setExperimentalOption("prefs", chromePrefs);
File file1 = new File("C:\\\\Users\\\\MohanNiru\\\\Downloads\\ExportedEstimate.xlsx");
if (file1.exists()) {
System.out.println("Downloaded file exist in the specified path");
}
driver.quit();
}
}