-
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
574cdf3
commit 3bcdf98
Showing
8 changed files
with
192 additions
and
2 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
67 changes: 67 additions & 0 deletions
67
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,67 @@ | ||
/* | ||
* 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.PluginPropertyUtils; | ||
import io.cdap.e2e.utils.SeleniumHelper; | ||
import io.cdap.e2e.utils.WaitHelper; | ||
import java.io.IOException; | ||
import static io.cdap.e2e.utils.ConstantsUtil.CDFPASSWORD; | ||
import static io.cdap.e2e.utils.ConstantsUtil.CDFUSERNAME; | ||
|
||
|
||
/** | ||
* Represents CdfSignInActions | ||
*/ | ||
public class CdfSignInActions { | ||
private static CdfSignInLocator cdfSignInLocator; | ||
static { | ||
cdfSignInLocator = SeleniumHelper.getPropertiesLocators(CdfSignInLocator.class); | ||
} | ||
|
||
public static void login() throws IOException { | ||
ElementHelper.sendKeys(cdfSignInLocator.cdfUsername, SeleniumHelper.readParameters(CDFUSERNAME)); | ||
ElementHelper.clickOnElement(cdfSignInLocator.nextButton); | ||
ElementHelper.sendKeys(cdfSignInLocator.cdfPassword, SeleniumHelper.readParameters(CDFPASSWORD)); | ||
ElementHelper.clickOnElement(cdfSignInLocator.nextButton); | ||
|
||
// Adding optional operations here. | ||
|
||
/* | ||
Based on the observations in case of CDF test execution from local we encounter Allow Button | ||
and in case of CDF test execution from Cloud Build we encounter Continue Button that's why we | ||
are using 2 confirmation buttons here. | ||
*/ | ||
|
||
String testAccountName = PluginPropertyUtils.pluginProp("testAccountName"); | ||
ElementHelper.clickIfDisplayed(cdfSignInLocator.selectTestAccount(testAccountName), | ||
ConstantsUtil.MEDIUM_TIMEOUT_SECONDS, cdfSignInLocator.clickOnAllowButton()); | ||
|
||
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnContinueButton(), ConstantsUtil.MEDIUM_TIMEOUT_SECONDS, | ||
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source")); | ||
|
||
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnAllowButton(), ConstantsUtil.MEDIUM_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
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