Update the Instagram login process

Signed-off-by: Tomas Ondrusko <tondrusk@redhat.com>
This commit is contained in:
Tomas Ondrusko 2023-08-23 15:29:21 +02:00 committed by Hynek Mlnařík
parent 469c306cd5
commit 58131f1dcc

View file

@ -37,11 +37,8 @@ public class InstagramLoginPage extends AbstractSocialLoginPage {
@FindBy(xpath = "//button[text()='Save Info']") @FindBy(xpath = "//button[text()='Save Info']")
private WebElement saveInfoBtn; private WebElement saveInfoBtn;
@FindBy(xpath = "//button[text()='Authorize']") @FindBy(xpath = "//span[text()='Allow']")
private WebElement authorizeBtn; private WebElement allowSpan;
@FindBy(xpath = "//button[text()='Continue']")
private WebElement continueBtn;
@Override @Override
public void login(String user, String password) { public void login(String user, String password) {
@ -50,26 +47,26 @@ public class InstagramLoginPage extends AbstractSocialLoginPage {
usernameInput.sendKeys(user); usernameInput.sendKeys(user);
passwordInput.sendKeys(password); passwordInput.sendKeys(password);
passwordInput.sendKeys(Keys.RETURN); passwordInput.sendKeys(Keys.RETURN);
pause(2000); // wait for the login screen a bit pause(3000);
try { try {
saveInfoBtn.click(); saveInfoBtn.click();
pause(3000);
} }
catch (NoSuchElementException e) { catch (NoSuchElementException e) {
log.info("'Save Info' button not found, ignoring"); log.info("'Save Info' button not found, ignoring");
pause(2000); // wait for the login screen a bit pause(3000);
} }
} }
catch (NoSuchElementException e) { catch (NoSuchElementException e) {
log.info("Instagram is already logged in, just confirmation is expected"); log.info("Instagram is already logged in, just confirmation is expected");
} }
// Approval dialog
try { try {
continueBtn.click(); allowSpan.click();
} } catch (NoSuchElementException e) {
catch (NoSuchElementException e) { log.info("'Allow' button not found, ignoring");
log.info("'Continue' button not found, trying 'Authorize'...");
authorizeBtn.click();
} }
} }
} }