mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-05 18:42:55 +00:00
bug5905: enabled and fixed finally last part of Race Manager App QR code test, after production environment was updated to new QR code handling
- cleaned up code - did some more stabilization by changing the central PageObject.findElementBySeleniumId to a Selenium wait.
This commit is contained in:
1 parent
0295859982
commit
ebfcba1fdc
5 files changed
+65
-59
No files matched your search
+4
-2
@@ -383,6 +383,7 @@ public class PageObject {
|
||||
/**
|
||||
* <p>Finds and returns the first element with the specified selenium id in the given search context. If multiple
|
||||
* elements exists, the element closest to the context is returned.</p>
|
||||
* <p>To be more stable this search is based on a web driver wait. Default lookup timeout is used.
|
||||
*
|
||||
* @param context
|
||||
* The search context to use for the search.
|
||||
@@ -391,8 +392,9 @@ public class PageObject {
|
||||
* @return
|
||||
* The first matching element in the given context.
|
||||
*/
|
||||
protected WebElement findElementBySeleniumId(SearchContext context, String id) {
|
||||
return context.findElement(new BySeleniumId(id));
|
||||
protected WebElement findElementBySeleniumId(SearchContext context, String seleniumId) {
|
||||
WebDriverWait webDriverWait = new WebDriverWait(driver, DEFAULT_LOOKUP_TIMEOUT);
|
||||
return webDriverWait.until(ExpectedConditions.presenceOfElementLocated(new BySeleniumId(seleniumId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-5
@@ -1,9 +1,6 @@
|
||||
package com.sap.sailing.selenium.pages.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.openqa.selenium.Alert;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
@@ -69,13 +66,11 @@ public abstract class DataEntryDialogPO extends PageArea {
|
||||
Wait<WebDriver> wait = new WebDriverWait(driver, 20);
|
||||
// click OK
|
||||
wait.until(ExpectedConditions.elementToBeClickable(okButton)).click();
|
||||
|
||||
if (acceptAlert) {
|
||||
final Alert alert = new WebDriverWait(driver, DEFAULT_WAIT_TIMEOUT_SECONDS)
|
||||
.until(ExpectedConditions.alertIsPresent());
|
||||
alert.accept();
|
||||
}
|
||||
|
||||
if (waitForAjaxRequests) {
|
||||
// Wait, since we do a callback usually
|
||||
waitForAjaxRequests();
|
||||
|
||||
+44
-43
@@ -45,7 +45,7 @@ import com.sap.sailing.selenium.test.adminconsole.smartphonetracking.RegisterCom
|
||||
* There are various link creation logic in AdminConsole. This test is to cover them.
|
||||
*/
|
||||
public class TestLinkCreation extends AbstractSeleniumTest {
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestLinkCreation.class);
|
||||
|
||||
private static final String DEVICE_CONFIG_NAME = "Test";
|
||||
@@ -63,14 +63,13 @@ public class TestLinkCreation extends AbstractSeleniumTest {
|
||||
private static final String CUSTOM_COURSE_AREA = "Custom X";
|
||||
private static final String INVITATION_URL_BASE = "https://sailinsight30-app.sapsailing.com/publicInvite?regatta_name=Audi+Business+Cup+(J70)+(J70)";
|
||||
private static final String INVITATION_QR_CODE_BASE = "https://sailinsight30-app.sapsailing.com/publicInvite?regatta_name=Audi%20Business%20Cup%20(J70)%20(J70)";
|
||||
private static final String EXPECTED_PUPLIC_INVITE_QR_CODE_TITLE = "Welcome to the public regatta Audi Business Cup (J70) (J70)";
|
||||
// private static final String EXPECTED_RACE_MANAGER_APP_QR_CODE_TITLE = "Welcome to the Race Manager App registration";
|
||||
private static final String EXPECTED_PUPLIC_INVITE_QR_CODE_TITLE = "Welcome to the public regatta Audi Business Cup (J70) (J70)";
|
||||
private static final String EXPECTED_RACE_MANAGER_APP_QR_CODE_TITLE = "Welcome to the Race Manager App registration";
|
||||
private static final String EXPECTED_DEVICE_REGISTRATION_QR_CODE_TITLE = "Welcome Competitor Test to the regatta Audi Business Cup (J70) (J70)";
|
||||
private static final String EXPECTED_QR_LINK_TEXT = "Please scan this QR Code with your mobile device to proceed with the registration";
|
||||
|
||||
private static final String CHECK_RACE_APP_URL_REGEX = "^https:\\/\\/racemanager-app.sapsailing.com\\/invite\\"
|
||||
+ "?server_url=http:\\/\\/localhost(:\\d{0,5})?"
|
||||
+ "&device_config_identifier=" + DEVICE_CONFIG_NAME
|
||||
+ "?server_url=http.*localhost.*(\\d{0,5})?" + "&device_config_identifier=" + DEVICE_CONFIG_NAME
|
||||
+ "&device_config_uuid=(\\w|\\d|-)*";
|
||||
|
||||
private static final String DEVICE_REGISTRATION_URL_REGEX = ".*https:\\/\\/sailinsight30-app.sapsailing.com\\/invite\\?checkinUrl=.*";
|
||||
@@ -85,11 +84,13 @@ public class TestLinkCreation extends AbstractSeleniumTest {
|
||||
(new URL(prodCheckUrl)).openStream().close();
|
||||
checkUrlIsWorking = true;
|
||||
LOG.info("Productive server {} is accessible.", prodCheckUrl);
|
||||
} catch (Exception ex) {
|
||||
checkUrlIsWorking = false;
|
||||
LOG.warn("Productive server {} is NOT accessible. Skip tests which are requirering live connection.", prodCheckUrl);
|
||||
}
|
||||
Assume.assumeTrue("Execute link creation test only if productive server is online (www.sapsailing.com).", checkUrlIsWorking);
|
||||
} catch (Exception ex) {
|
||||
checkUrlIsWorking = false;
|
||||
LOG.warn("Productive server {} is NOT accessible. Skip tests which are requirering live connection.",
|
||||
prodCheckUrl);
|
||||
}
|
||||
Assume.assumeTrue("Execute link creation test only if productive server is online (www.sapsailing.com).",
|
||||
checkUrlIsWorking);
|
||||
clearState(getContextRoot());
|
||||
super.setUp();
|
||||
}
|
||||
@@ -131,11 +132,11 @@ public class TestLinkCreation extends AbstractSeleniumTest {
|
||||
HomePage.goToHomeUrl(getWebDriver(), createdInvitationUrl);
|
||||
Wait<WebDriver> wait = new WebDriverWait(getWebDriver(), 30);
|
||||
// confirm dialog on my.sapsailing.com to redirect back to localhost
|
||||
wait.until(ExpectedConditions.numberOfElementsToBe(By.xpath("//button[contains(text(), 'Yes')] | //button[contains(text(), 'Ja')]"), 1)).get(0)
|
||||
.click();
|
||||
wait.until(ExpectedConditions.numberOfElementsToBe(
|
||||
By.xpath("//button[contains(text(), 'Yes')] | //button[contains(text(), 'Ja')]"), 1)).get(0).click();
|
||||
// here we are back on localhost (Home.html#QRCodePlace)
|
||||
wait.until(ExpectedConditions
|
||||
.presenceOfElementLocated(By.xpath("//div[contains(text(), '" + EXPECTED_PUPLIC_INVITE_QR_CODE_TITLE + "')]")));
|
||||
wait.until(ExpectedConditions.presenceOfElementLocated(
|
||||
By.xpath("//div[contains(text(), '" + EXPECTED_PUPLIC_INVITE_QR_CODE_TITLE + "')]")));
|
||||
WebElement qrCodeLink = wait.until(ExpectedConditions
|
||||
.presenceOfElementLocated(By.xpath("//a[contains(text(), '" + EXPECTED_QR_LINK_TEXT + "')]")));
|
||||
Assert.assertTrue(qrCodeLink.getAttribute("href").startsWith(INVITATION_QR_CODE_BASE));
|
||||
@@ -157,25 +158,23 @@ public class TestLinkCreation extends AbstractSeleniumTest {
|
||||
DeviceConfigurationQRCodeDialogPO qrCodeDialog = deviceConfigurationDetails.openQRCodeDialog();
|
||||
Matcher<String> matcher = Matchers.matchesRegex(CHECK_RACE_APP_URL_REGEX);
|
||||
String createdInvitationUrl = qrCodeDialog.getUrl();
|
||||
MatcherAssert.assertThat("Check URL", matcher.matches(createdInvitationUrl));
|
||||
MatcherAssert.assertThat("Check URL", matcher.matches(createdInvitationUrl));
|
||||
HomePage.goToHomeUrl(getWebDriver(), createdInvitationUrl);
|
||||
/* Activate after setting up branch.io correctly */
|
||||
// TODO: reactivate after branch.io is handling Race Manager App links the new way
|
||||
// confirm dialog on my.sapsailing.com to redirect back to localhost
|
||||
// Wait<WebDriver> wait = new WebDriverWait(getWebDriver(), 30);
|
||||
// wait.until(ExpectedConditions.numberOfElementsToBe(By.xpath("//button[contains(text(), 'Yes')] | //button[contains(text(), 'Ja')]"), 1)).get(0)
|
||||
// .click();
|
||||
// // here we are back on localhost (Home.html#QRCodePlace)
|
||||
// wait.until(ExpectedConditions
|
||||
// .presenceOfElementLocated(By.xpath("//div[contains(text(), '" + EXPECTED_RACE_MANAGER_APP_QR_CODE_TITLE + "')]")));
|
||||
// WebElement qrCodeLink = wait.until(ExpectedConditions
|
||||
// .presenceOfElementLocated(By.xpath("//a[contains(text(), '" + EXPECTED_QR_LINK_TEXT + "')]")));
|
||||
// MatcherAssert.assertThat("Check URL", matcher.matches(qrCodeLink));
|
||||
|
||||
Wait<WebDriver> wait = new WebDriverWait(getWebDriver(), 30);
|
||||
wait.until(ExpectedConditions.numberOfElementsToBe(
|
||||
By.xpath("//button[contains(text(), 'Yes')] | //button[contains(text(), 'Ja')]"), 1)).get(0).click();
|
||||
// here we are back on localhost (Home.html#QRCodePlace)
|
||||
wait.until(ExpectedConditions.presenceOfElementLocated(
|
||||
By.xpath("//div[contains(text(), '" + EXPECTED_RACE_MANAGER_APP_QR_CODE_TITLE + "')]")));
|
||||
WebElement qrCodeLink = wait.until(ExpectedConditions
|
||||
.presenceOfElementLocated(By.xpath("//a[contains(text(), '" + EXPECTED_QR_LINK_TEXT + "')]")));
|
||||
MatcherAssert.assertThat("Check URL", matcher.matches(qrCodeLink.getAttribute("href")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@@ -193,10 +192,15 @@ public class TestLinkCreation extends AbstractSeleniumTest {
|
||||
SmartphoneTrackingEventManagementPanelPO smartphoneTrackingPanel = adminConsole.goToSmartphoneTrackingPanel();
|
||||
DataEntryPO aLeaderboard = smartphoneTrackingPanel.getLeaderboardTable().getEntries().get(0);
|
||||
// Add a competitor with boat as precondition for adding devices
|
||||
RegisterCompetitorsDialogPO registerCompetitorsDialogPO = smartphoneTrackingPanel.pushCompetitorRegistrationsActionButton(aLeaderboard);
|
||||
AddCompetitorWithBoatDialogPO addCompetitorWithBoatDialogPO = registerCompetitorsDialogPO.openAddCompetitorWithBoatDialog();
|
||||
RegisterCompetitorsDialogPO registerCompetitorsDialogPO = smartphoneTrackingPanel
|
||||
.pushCompetitorRegistrationsActionButton(aLeaderboard);
|
||||
AddCompetitorWithBoatDialogPO addCompetitorWithBoatDialogPO = registerCompetitorsDialogPO
|
||||
.openAddCompetitorWithBoatDialog();
|
||||
addCompetitorWithBoatDialogPO.addCompetitorWithBoat();
|
||||
Thread.sleep(200L);
|
||||
Wait<WebDriver> wait = new WebDriverWait(getWebDriver(), 30);
|
||||
// wait until competitor is shown in the table. Sometimes test breaks here if dialog was closed to early
|
||||
wait.until((s) -> registerCompetitorsDialogPO.getCompetitorTable().getEntries().size() > 0);
|
||||
// now close the dialog
|
||||
registerCompetitorsDialogPO.clickOkButtonOrThrow();
|
||||
// Add device
|
||||
aLeaderboard = smartphoneTrackingPanel.getLeaderboardTable().getEntries().get(0);
|
||||
@@ -206,28 +210,25 @@ public class TestLinkCreation extends AbstractSeleniumTest {
|
||||
addDeviceMappingsDialog.getBoatsTable().getEntries().get(0).select();
|
||||
String boatUrlPattern = DEVICE_REGISTRATION_URL_REGEX + "boat_id.*";
|
||||
Matcher<String> boatMatcher = Matchers.matchesRegex(boatUrlPattern);
|
||||
MatcherAssert.assertThat("Check URL", boatMatcher.matches(addDeviceMappingsDialog.getQrCodeUrl(boatUrlPattern)));
|
||||
MatcherAssert.assertThat("Check URL",
|
||||
boatMatcher.matches(addDeviceMappingsDialog.getQrCodeUrl(boatUrlPattern)));
|
||||
// check URL based on competitor selection
|
||||
addDeviceMappingsDialog.getCompetitorTable().getEntries().get(0).select();
|
||||
String compatitorUrlPattern = DEVICE_REGISTRATION_URL_REGEX + "competitor_id.*";
|
||||
Matcher<String> competitorMater = Matchers.matchesRegex(compatitorUrlPattern);
|
||||
String qrCodeUrl = addDeviceMappingsDialog.getQrCodeUrl(compatitorUrlPattern);
|
||||
MatcherAssert.assertThat("Check URL", competitorMater.matches(qrCodeUrl));
|
||||
MatcherAssert.assertThat("Check URL", competitorMater.matches(qrCodeUrl));
|
||||
// check redirect
|
||||
//HomePage.goToHomeUrl(getWebDriver(), qrCodeUrl);
|
||||
getWebDriver().get(qrCodeUrl);
|
||||
Wait<WebDriver> wait = new WebDriverWait(getWebDriver(), 30);
|
||||
// confirm dialog on my.sapsailing.com to redirect back to localhost
|
||||
wait.until(ExpectedConditions.numberOfElementsToBe(By.xpath("//button[contains(text(), 'Yes')] | //button[contains(text(), 'Ja')]"), 1)).get(0)
|
||||
.click();
|
||||
wait.until(ExpectedConditions.numberOfElementsToBe(
|
||||
By.xpath("//button[contains(text(), 'Yes')] | //button[contains(text(), 'Ja')]"), 1)).get(0).click();
|
||||
// here we are back on localhost (Home.html#QRCodePlace)
|
||||
wait.until(ExpectedConditions
|
||||
.presenceOfElementLocated(By.xpath("//div[contains(text(), '" + EXPECTED_DEVICE_REGISTRATION_QR_CODE_TITLE + "')]")));
|
||||
wait.until(ExpectedConditions.presenceOfElementLocated(
|
||||
By.xpath("//div[contains(text(), '" + EXPECTED_DEVICE_REGISTRATION_QR_CODE_TITLE + "')]")));
|
||||
WebElement qrCodeLink = wait.until(ExpectedConditions
|
||||
.presenceOfElementLocated(By.xpath("//a[contains(text(), '" + EXPECTED_QR_LINK_TEXT + "')]")));
|
||||
Matcher<String> matcher = Matchers.matchesRegex(compatitorUrlPattern);
|
||||
LOG.debug("Check URL expected pattern: " + compatitorUrlPattern);
|
||||
LOG.debug("Check URL link: " + qrCodeLink.getAttribute("href"));
|
||||
MatcherAssert.assertThat("Check URL", matcher.matches(qrCodeLink.getAttribute("href")));
|
||||
MatcherAssert.assertThat("Check URL", matcher.matches(qrCodeLink.getAttribute("href")));
|
||||
}
|
||||
}
|
||||
-2
@@ -40,8 +40,6 @@ public class AddDeviceMappingsDialogPO extends DataEntryDialogPO {
|
||||
}
|
||||
|
||||
public String getQrCodeUrl(String matcherPattern) {
|
||||
// Wait<WebDriver> wait = new WebDriverWait(driver, 10);
|
||||
// wait.until(ExpectedConditions.visibilityOf(qrCodeUrl));
|
||||
waitUntil(webDriver -> Pattern.compile(matcherPattern).matcher(qrCodeUrl.getText()).matches());
|
||||
return qrCodeUrl.getText();
|
||||
}
|
||||
|
||||
+17
-7
@@ -2,28 +2,38 @@ package com.sap.sailing.selenium.test.adminconsole.smartphonetracking;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.Wait;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesCompetitorTablePO;
|
||||
import com.sap.sailing.selenium.pages.common.DataEntryDialogPO;
|
||||
|
||||
public class RegisterCompetitorsDialogPO extends DataEntryDialogPO {
|
||||
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "registerCompetitorsDialog")
|
||||
private WebElement dialog;
|
||||
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "addCompetitorWithBoatButton")
|
||||
private WebElement addCompetitorWithBoatButton;
|
||||
|
||||
|
||||
public RegisterCompetitorsDialogPO(WebDriver driver, WebElement element) {
|
||||
super(driver, element);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public AddCompetitorWithBoatDialogPO openAddCompetitorWithBoatDialog() {
|
||||
this.addCompetitorWithBoatButton.click();
|
||||
return getPO(AddCompetitorWithBoatDialogPO::new, "CompetitorWithBoatEditDialog");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TrackedRacesCompetitorTablePO getCompetitorTable() {
|
||||
Wait<WebDriver> wait = new WebDriverWait(driver, 10);
|
||||
WebElement competitorTable = wait
|
||||
.until(ExpectedConditions.presenceOfElementLocated(new BySeleniumId("CompetitorsTable")));
|
||||
return new TrackedRacesCompetitorTablePO(this.driver, competitorTable);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user