22
33import org .openqa .selenium .By ;
44import org .openqa .selenium .JavascriptExecutor ;
5+ import org .openqa .selenium .NoSuchElementException ;
56import org .openqa .selenium .WebDriver ;
67import org .openqa .selenium .WebElement ;
78import org .openqa .selenium .chrome .ChromeDriver ;
@@ -51,9 +52,9 @@ public static void randomSleep(int sleep) {
5152 driver = new ChromeDriver ();
5253 driver .manage ().timeouts ().implicitlyWait (Duration .ofSeconds (10 ));
5354 js = (JavascriptExecutor ) driver ;
54- MUST_NOT_HAVE = new ArrayList <String >(Arrays .asList ("architect" , "devops" , "principal" , "lead" , "net" , "nodejs" , "node js" , "c" ));
55+ MUST_NOT_HAVE = new ArrayList <String >(Arrays .asList ("architect" , "devops" , "principal" , "lead" , "net" , "nodejs" , "w2" , " node" , " js" , "c" ));
5556 MUST_HAVE = new ArrayList <String >(
56- Arrays .asList ("senior" , "java" , "full" , "stack" , "microservices" , "engineer " , "software " , "backend" , "spring" , "boot" , "frontend" ));
57+ Arrays .asList ("senior" , "java" , "full" , "stack" , "microservices" , "software " , "back" , "front " , "backend" , "spring" , "boot" , "frontend" ));
5758 scanner = new Scanner (System .in );
5859 rand = new Random ();
5960 Properties properties = new Properties ();
@@ -99,6 +100,7 @@ public static void main(String[] args) {
99100 scrollToWebElement (view );
100101 // get the aria label in this element as job Title In Card,
101102 // if it contains any of the MUST_HAVE, then click on the card
103+ //
102104 WebElement aTag = view .findElement (By .cssSelector (".disabled.ember-view.job-card-container__link.job-card-list__title" ));
103105
104106 // Extract the aria-label content
@@ -110,7 +112,7 @@ public static void main(String[] args) {
110112 i ++;
111113
112114 // process job Title in Card by removing special characters with space and split the job Title into words
113- jobTitleInCard = jobTitleInCard .replaceAll ("[^a-zA-Z0-9]" , " " ).toLowerCase ();
115+ jobTitleInCard = jobTitleInCard .trim (). replaceAll ("[^a-zA-Z0-9]" , " " ).toLowerCase ();
114116 String [] jobTitleInCardWords = jobTitleInCard .split (" " );
115117
116118 // check if any of the MUST_HAVE words are in the job Title in Card
@@ -132,24 +134,7 @@ public static void main(String[] args) {
132134
133135 chooseToApply (scanner );
134136 }
135- // click on the next page
136- // List<WebElement> resultPages = driver.findElements(By.xpath(
137- // "/html/body/div[4]/div[3]/div[4]/div/div/main/div/div[1]/div/div[5]/ul/li"));
138-
139- // logger.info("There are " + resultPages.size() + " pages of results");
140- // int page = 1;
141- // for (WebElement pageButton : resultPages) {
142- // scrollToWebElement(pageButton);
143- // randomSleep(SHORT_SLEEP);
144- // pageButton.click();
145- // logger.info("Page " + page + " of " + resultPages.size());
146- // randomSleep(MEDIUM_SLEEP);
147- // jobCards = driver
148- // .findElements(By.xpath("/html/body/div[5]/div[3]/div[4]/div/div/main/div/div[1]/div/ul/li"));
149- // logger.info("There are " + jobCards.size() + " jobs on this page");
150- // page++;
151- // }
152- // randomSleep(MEDIUM_SLEEP);
137+
153138 choice = offerUserChoices ();
154139 } while (choice );
155140 // close the browser
@@ -255,27 +240,24 @@ private static void applyForThisJob() {
255240 // submit button xpath:
256241 // /html/body/div[3]/div/div/div[2]/div/div[2]/div/footer/div[3]/button[2]
257242 /// html/body/div[3]/div/div/div[2]/div/div[2]/div/footer/div[2]/button[2]
258-
259- } catch (Exception e ) {
260- //log exception message
261- //print stack trace to output
262- e .printStackTrace ();
243+ // scroll to the submit button
244+ WebElement submitButton = driver .findElement (By .xpath (
245+ "/html/body/div[3]/div/div/div[2]/div/div[2]/div/footer" )).findElement (By .cssSelector (".artdeco-button--primary.ember-view" ));
246+ scrollToWebElement (submitButton );
247+ submitButton .click ();
248+ randomSleep (LONG_SLEEP );
249+
250+ WebElement closeButton = driver .findElement (By .xpath ("/html/body/div[3]/div/div/button" ));
251+ closeButton .click ();
252+
253+ } catch (NoSuchElementException e ){
254+ logger .info ("Issue sumbitting application \n Sumbit manually and press enter to continue" );
255+ scanner .nextLine ();
256+ }
257+ catch (Exception e ) {
263258 logger .info (e .getMessage ());
264- // logger.info("Please submit the application manually");
265- // // Send user press to continue
266- // scanner.nextLine();
267- // return;
268- /// html/body/div[3]/div/div/div[2]/div/div/form/footer/div[3]/button
269259 }
270- // scroll to the submit button
271- WebElement submitButton = driver .findElement (By .xpath (
272- "/html/body/div[3]/div/div/div[2]/div/div[2]/div/footer" )).findElement (By .cssSelector (".artdeco-button--primary.ember-view" ));
273- scrollToWebElement (submitButton );
274- submitButton .click ();
275- randomSleep (LONG_SLEEP );
276260
277- WebElement closeButton = driver .findElement (By .xpath ("/html/body/div[3]/div/div/button" ));
278- closeButton .click ();
279261 // Sleep for 5 secondsn
280262
281263 }
0 commit comments