Skip to content

Commit 7c2c760

Browse files
author
Asish Das
committed
Fixed chrome driver issue and updated pwd
1 parent ee1756c commit 7c2c760

File tree

2 files changed

+114
-54
lines changed

2 files changed

+114
-54
lines changed

IRISTicketTracker/Program.cs

Lines changed: 113 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Threading.Tasks;
1515
using JnJ.EAS.TicketTracker.Core;
1616
using JnJ.EAS.TicketTracker.Core.Models;
17+
using System.Threading;
1718

1819
namespace IRISTicketTracker
1920
{
@@ -127,6 +128,7 @@ public static void OpenServiceRequestReport()
127128

128129
var options = new ChromeOptions();
129130
options.AddArgument("headless");
131+
options.AddArgument("--DNS-prefetch-disable");
130132

131133
IWebDriver driver;
132134
driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options)
@@ -139,39 +141,68 @@ public static void OpenServiceRequestReport()
139141
IWebElement frame = (new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
140142
.Until(d => d.FindElement(By.Id("gsft_main")));
141143

142-
driver.SwitchTo().Frame(frame);
144+
driver.SwitchTo().Frame(frame);
143145

144-
// let's build a list of tickets
145-
var tbody = (new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
146-
.Until(d => d.FindElement(By.ClassName("list2_body")));
146+
var totalRows = Convert.ToInt32((new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
147+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_total_rows')]")).Text));
147148

149+
var lastRow = Convert.ToInt32((new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
150+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_last_row')]")).Text));
148151

149-
int rowCount = tbody.FindElements(By.TagName("tr")).Count;
150-
int colCount = (tbody.FindElements(By.TagName("tr"))[0]).FindElements(By.ClassName("vt")).Count;
152+
var counter = 0;
151153

152-
foreach (var rowItem in tbody.FindElements(By.TagName("tr")))
154+
do
153155
{
154-
var cells = rowItem.FindElements(By.ClassName("vt"));
155-
Report report = new Report()
156+
// let's build a list of tickets
157+
var tbody = (new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
158+
.Until(d => d.FindElement(By.ClassName("list2_body")));
159+
160+
161+
int rowCount = tbody.FindElements(By.TagName("tr")).Count;
162+
int colCount = (tbody.FindElements(By.TagName("tr"))[0]).FindElements(By.ClassName("vt")).Count;
163+
164+
foreach (var rowItem in tbody.FindElements(By.TagName("tr")))
165+
{
166+
var cells = rowItem.FindElements(By.ClassName("vt"));
167+
Report report = new Report()
168+
{
169+
Numnber = cells[0].Text,
170+
ApplicationID = cells[1].Text,
171+
ApplicationName = cells[2].Text,
172+
Priority = cells[3].Text,
173+
State = cells[4].Text,
174+
AssignedTo = cells[5].Text,
175+
ShortDescription = cells[6].Text,
176+
AssignmentGroup = cells[7].Text,
177+
TaskType = cells[8].Text,
178+
Opened = cells[9].Text,
179+
CustTime = cells[10].Text,
180+
Duration = cells[11].Text,
181+
Status = cells[12].Text,
182+
TaskState = cells[13].Text
183+
};
184+
185+
lstSRReport.Add(report);
186+
}
187+
188+
if (counter != 0)
156189
{
157-
Numnber = cells[0].Text,
158-
ApplicationID = cells[1].Text,
159-
ApplicationName = cells[2].Text,
160-
Priority = cells[3].Text,
161-
State = cells[4].Text,
162-
AssignedTo = cells[5].Text,
163-
ShortDescription = cells[6].Text,
164-
AssignmentGroup = cells[7].Text,
165-
TaskType = cells[8].Text,
166-
Opened = cells[9].Text,
167-
CustTime = cells[10].Text,
168-
Duration = cells[11].Text,
169-
Status = cells[12].Text,
170-
TaskState = cells[13].Text
171-
};
172-
173-
lstSRReport.Add(report);
190+
//let's hit next page button
191+
var nextBtn = (new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
192+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_next')]")));
193+
194+
nextBtn.Click();
195+
196+
Thread.Sleep(30000);
197+
198+
lastRow = Convert.ToInt32((new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
199+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_last_row')]")).Text));
200+
201+
}
202+
203+
counter++;
174204
}
205+
while (lastRow < totalRows);
175206

176207
driver.Close();
177208
driver.Quit();
@@ -210,39 +241,68 @@ public static void OpenIncidentReport()
210241

211242
driver.SwitchTo().Frame(frame);
212243

213-
// let's build a list of tickets
214-
var tbody = (new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
215-
.Until(d => d.FindElement(By.ClassName("list2_body")));
244+
var totalRows = Convert.ToInt32((new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
245+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_total_rows')]")).Text));
216246

247+
var lastRow = Convert.ToInt32((new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
248+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_last_row')]")).Text));
217249

218-
int rowCount = tbody.FindElements(By.TagName("tr")).Count;
219-
int colCount = (tbody.FindElements(By.TagName("tr"))[0]).FindElements(By.ClassName("vt")).Count;
250+
var counter = 0;
220251

221-
foreach (var rowItem in tbody.FindElements(By.TagName("tr")))
252+
do
222253
{
223-
var cells = rowItem.FindElements(By.ClassName("vt"));
224-
IncidentReport report = new IncidentReport()
254+
// let's build a list of tickets
255+
var tbody = (new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
256+
.Until(d => d.FindElement(By.ClassName("list2_body")));
257+
258+
259+
int rowCount = tbody.FindElements(By.TagName("tr")).Count;
260+
int colCount = (tbody.FindElements(By.TagName("tr"))[0]).FindElements(By.ClassName("vt")).Count;
261+
262+
foreach (var rowItem in tbody.FindElements(By.TagName("tr")))
225263
{
226-
Numnber = cells[0].Text,
227-
ApplicationID = cells[1].Text,
228-
ApplicationName = cells[2].Text,
229-
Priority = cells[3].Text,
230-
ShortDescription = cells[4].Text,
231-
State = cells[5].Text,
232-
AssignedTo = cells[6].Text,
233-
Opened = cells[7].Text,
234-
Resolved = cells[8].Text,
235-
Closed = cells[9].Text,
236-
Category = cells[10].Text,
237-
Status = cells[11].Text,
238-
AssignmentGroup = cells[12].Text,
239-
ResolutionCategory = cells[13].Text,
240-
ResolutionCode = cells[14].Text,
241-
KCS = cells[15].Text
242-
};
243-
244-
lstIncReport.Add(report);
264+
var cells = rowItem.FindElements(By.ClassName("vt"));
265+
IncidentReport report = new IncidentReport()
266+
{
267+
Numnber = cells[0].Text,
268+
ApplicationID = cells[1].Text,
269+
ApplicationName = cells[2].Text,
270+
Priority = cells[3].Text,
271+
ShortDescription = cells[4].Text,
272+
State = cells[5].Text,
273+
AssignedTo = cells[6].Text,
274+
Opened = cells[7].Text,
275+
Resolved = cells[8].Text,
276+
Closed = cells[9].Text,
277+
Category = cells[10].Text,
278+
Status = cells[11].Text,
279+
AssignmentGroup = cells[12].Text,
280+
ResolutionCategory = cells[13].Text,
281+
ResolutionCode = cells[14].Text,
282+
KCS = cells[15].Text
283+
};
284+
285+
lstIncReport.Add(report);
286+
}
287+
288+
if (counter != 0)
289+
{
290+
//let's hit next page button
291+
var nextBtn = (new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
292+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_next')]")));
293+
294+
nextBtn.Click();
295+
296+
Thread.Sleep(30000);
297+
298+
lastRow = Convert.ToInt32((new WebDriverWait(driver, TimeSpan.FromMinutes(1)))
299+
.Until(d => d.FindElement(By.XPath("//*[contains(@id,'_last_row')]")).Text));
300+
301+
}
302+
303+
counter++;
245304
}
305+
while (lastRow < totalRows);
246306

247307
driver.Close();
248308
driver.Quit();

IRISTicketTracker/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"AppSettings": {
66
"SharePointLoginID": "[email protected]",
7-
"SharePointLoginPWD": "Kolkata-7",
7+
"SharePointLoginPWD": "Kolkata-8",
88
"SharePointCRSiteUrl": "https://jnj.sharepoint.com/teams/eas/AM",
99
"SharePointCRListName": "EAS Change Tracker",
1010
"MailSMTPServer": "smtp.na.jnj.com",

0 commit comments

Comments
 (0)