-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* landing jobs integration * remove unwanted file * trim spaces on titles * fix readme menu
- Loading branch information
Sérgio Martins
committed
Oct 24, 2020
1 parent
dfed19f
commit 59e7b30
Showing
8 changed files
with
516 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/qa/vacancies/portugal/pages/LandingJobsPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package qa.vacancies.portugal.pages; | ||
|
||
import com.codeborne.selenide.SelenideElement; | ||
import qa.vacancies.portugal.utils.constants.Constants; | ||
import qa.vacancies.portugal.utils.model.Vacancy; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import static com.codeborne.selenide.Condition.visible; | ||
import static com.codeborne.selenide.Selenide.$; | ||
import static com.codeborne.selenide.Selenide.$$; | ||
import static com.codeborne.selenide.Selenide.open; | ||
|
||
public class LandingJobsPage implements PageObject<LandingJobsPage> { | ||
private static final String SEARCH_SPINNER_SELECTOR = "#search_spinner"; | ||
private static final String CARD_SELECTOR = ".lj-jobcard "; | ||
private static final String TITLE_SELECTOR = ".lj-jobcard-name"; | ||
private static final String LIST_NAME_SELECTOR = ".lj-jobcard-company"; | ||
|
||
@Override | ||
public LandingJobsPage openAndSearch(String urlTemplate, Object... params) { | ||
Object[] nonNullParams = Arrays.stream(params).filter(Objects::nonNull).toArray(); | ||
open(String.format(urlTemplate, nonNullParams)); | ||
return this; | ||
} | ||
|
||
@Override | ||
public List<Vacancy> getVacancies() { | ||
$(SEARCH_SPINNER_SELECTOR).shouldNotBe(visible); | ||
|
||
return $$(CARD_SELECTOR) | ||
.stream() | ||
.filter(this::containsQuery) | ||
.map(element -> Vacancy.builder().title(getTitle(element)).company(getCompany(element)).url(getUrl(element)).build()) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private boolean containsQuery(SelenideElement element) { | ||
return Stream | ||
.of(Constants.KEYWORDS) | ||
.anyMatch(keyword -> element.$(TITLE_SELECTOR).innerText().toLowerCase().contains(keyword)); | ||
} | ||
|
||
private String getTitle(SelenideElement element) { | ||
return element.$(TITLE_SELECTOR).innerText().trim(); | ||
} | ||
|
||
private String getCompany(SelenideElement element) { | ||
return element.$(LIST_NAME_SELECTOR).innerText(); | ||
} | ||
|
||
private String getUrl(SelenideElement element) { | ||
return element.$(TITLE_SELECTOR).getAttribute("href"); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/qa/vacancies/portugal/vacancies/LandingJobsVacancies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package qa.vacancies.portugal.vacancies; | ||
|
||
import qa.vacancies.portugal.pages.LandingJobsPage; | ||
import qa.vacancies.portugal.pages.PageObject; | ||
import qa.vacancies.portugal.utils.model.Location; | ||
|
||
public class LandingJobsVacancies extends Vacancies { | ||
private static final String URL_TEMPLATE = "https://landing.jobs/jobs?page=1&location=%s&lr=0&match=all&country=PT&q=%s"; | ||
private static final String URL_TEMPLATE_REMOTE = "https://landing.jobs/jobs?page=1&lr=0&fr=true&match=all&q=%s"; | ||
|
||
private static final Location AVEIRO = Location.builder().urlTemplate(URL_TEMPLATE).id("Aveiro, Portugal&city=Aveiro").build(); | ||
private static final Location BRAGA = Location.builder().urlTemplate(URL_TEMPLATE).id("Braga, Portugal&city=Braga").build(); | ||
private static final Location COIMBRA = Location.builder().urlTemplate(URL_TEMPLATE).id("Coimbra, Portugal&city=Coimbra").build(); | ||
private static final Location LISBOA = Location.builder().urlTemplate(URL_TEMPLATE).id("Lisbon, Portugal&city=Lisbon").build(); | ||
private static final Location PORTO = Location.builder().urlTemplate(URL_TEMPLATE).id("Porto, Portugal&city=Porto").build(); | ||
private static final Location REMOTE = Location.builder().urlTemplate(URL_TEMPLATE_REMOTE).build(); | ||
|
||
private final PageObject<LandingJobsPage> landingJobsPage; | ||
|
||
public LandingJobsVacancies() { | ||
super(AVEIRO, BRAGA, COIMBRA, LISBOA, PORTO, REMOTE); | ||
landingJobsPage = new LandingJobsPage(); | ||
} | ||
|
||
@Override | ||
public StringBuilder stringBuilder() { | ||
StringBuilder sb = new StringBuilder(); | ||
appendWebsite(sb, "LandingJobs"); | ||
appendVacancies(sb, landingJobsPage); | ||
return sb; | ||
} | ||
} |