-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6322e1e
commit 8861cb5
Showing
9 changed files
with
238 additions
and
8 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
58 changes: 58 additions & 0 deletions
58
src/main/java/io/cdap/e2e/pages/actions/CdfSignInActions.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,58 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package io.cdap.e2e.pages.actions; | ||
|
||
import io.cdap.e2e.pages.locators.CdfSignInLocator; | ||
import io.cdap.e2e.utils.ConstantsUtil; | ||
import io.cdap.e2e.utils.ElementHelper; | ||
import io.cdap.e2e.utils.SeleniumHelper; | ||
import io.cdap.e2e.utils.WaitHelper; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
|
||
/** | ||
* Represents CdfSignInActions | ||
*/ | ||
public class CdfSignInActions { | ||
private static CdfSignInLocator cdfSignInLocator; | ||
static { | ||
cdfSignInLocator = SeleniumHelper.getPropertiesLocators(CdfSignInLocator.class); | ||
} | ||
|
||
public static void login() throws IOException, InterruptedException { | ||
ElementHelper.sendKeys(cdfSignInLocator.cdfUsername, SeleniumHelper.readParameters(ConstantsUtil.CDFUSERNAME)); | ||
ElementHelper.clickOnElement(cdfSignInLocator.nextButton); | ||
ElementHelper.sendKeys(cdfSignInLocator.cdfPassword, SeleniumHelper.readParameters(ConstantsUtil.CDFPASSWORD)); | ||
ElementHelper.clickOnElement(cdfSignInLocator.nextButton); | ||
|
||
ElementHelper.clickIfDisplayed(cdfSignInLocator.selectTestAccount(ConstantsUtil.CDF_TEST_ACCOUNT_NAME), | ||
ConstantsUtil.SMALL_TIMEOUT_SECONDS, cdfSignInLocator.clickOnContinueButton()); | ||
|
||
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnContinueButton(), ConstantsUtil.SMALL_TIMEOUT_SECONDS, | ||
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source")); | ||
|
||
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnAllowButton(), ConstantsUtil.SMALL_TIMEOUT_SECONDS, | ||
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source")); | ||
|
||
} | ||
|
||
public static boolean isUserLoggedInCDF() { | ||
return !WaitHelper.waitForElementToBeOptionallyDisplayed( | ||
CdfSignInLocator.locatorOfEmailTextBox(), ConstantsUtil.SMALL_TIMEOUT_SECONDS); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/io/cdap/e2e/pages/locators/CdfSignInLocator.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,58 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package io.cdap.e2e.pages.locators; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.openqa.selenium.support.How; | ||
|
||
/** | ||
* Represents CdfSignInLocators | ||
*/ | ||
public class CdfSignInLocator { | ||
|
||
@FindBy(how = How.XPATH, using = "//input[@name='identifier']") | ||
public WebElement cdfUsername; | ||
|
||
@FindBy(how = How.XPATH, using = "//input[@name='Passwd']") | ||
public WebElement cdfPassword; | ||
|
||
@FindBy(how = How.XPATH, using = "//*[contains(text(),'Next')]//parent::button") | ||
public WebElement nextButton; | ||
|
||
public static By locatorOfEmailTextBox() { | ||
return By.xpath("//input[@name='identifier']"); | ||
} | ||
|
||
public By selectTestAccount(String testAccountName) { | ||
return By.xpath("//*[contains(text(),'" + testAccountName + "')]"); | ||
} | ||
|
||
public By clickOnAllowButton() { | ||
return By.xpath("//button[contains(text(),'Allow')]"); | ||
} | ||
|
||
public By clickOnContinueButton() { | ||
return By.xpath("//span[contains(text(),'Continue')]"); | ||
} | ||
|
||
public static By locatePluginNameInList(String pluginName, String pluginGroupName) { | ||
return By.xpath("//div[@data-cy='plugin-" + pluginGroupName + "-group']" + | ||
"//div[contains(@class, 'PluginNameContainer')][normalize-space(text()) = '" + pluginName + "' " + | ||
"or translate(normalize-space(text()),' ','') = '" + pluginName + "']"); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package io.cdap.e2e.utils; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Retry Util | ||
*/ | ||
public class RetryUtils { | ||
|
||
/** | ||
* Implements a retry functionality for an action if required. | ||
* | ||
* @param retryDelay Delay in seconds after which each retry should be performed. | ||
* @param maxRetryDelay Max Delay in seconds after which retry logic should stop. | ||
* @param maxRetryCount Max Retry count after which retry logic should stop. | ||
* @param retryOperation Operation which needs to be performed while retrying. | ||
* | ||
*/ | ||
public static void retry(int retryDelay, int maxRetryDelay, int maxRetryCount, Supplier<Boolean> retryOperation) | ||
throws InterruptedException { | ||
int currentRetryDelay = 0; | ||
TimeUnit wait = TimeUnit.SECONDS; | ||
while (maxRetryCount > 0 && currentRetryDelay <= maxRetryDelay) { | ||
if (retryOperation.get()) { | ||
// If Operation succeeded, exit the retry loop. | ||
return; | ||
} | ||
|
||
currentRetryDelay += retryDelay; | ||
maxRetryCount--; | ||
|
||
wait.sleep(retryDelay); | ||
} | ||
} | ||
} |
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