Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated. Homework18 #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vladislav887139
Copy link

Replaced driver.findElement with wait.until().click();

@Berichicko
Copy link

You got this problem, please correct it.

image

HINT

image

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.Assert;
import org.testng.annotations.Test;

public class Homework18 extends BaseTest {


    @Test
    public void playSong() {
        launchBrowser();
        putinEmail("[email protected]");
        putinPassword("democlass");
        clickSubmit();
        clickPlay();
        Assert.assertTrue(isSongPlaying());
    }


    public void putinEmail(String email) {
        WebElement openEmail = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("input[type='email']")));
        openEmail.clear();
        openEmail.sendKeys(email);
    }
    public void putinPassword(String password) {
        WebElement openPassword = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("input[type='password']")));
        openPassword.clear();
        openPassword.sendKeys(password);
    }
    public void clickSubmit() {
        WebElement submitButton = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[type='submit']")));
        submitButton.click();
    }
    public void clickPlay() {
        WebElement PlayNextButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//i[@data-testid='play-next-btn']")));
        WebElement playButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[@data-testid='play-btn']")));
        PlayNextButton.click();
        playButton.click();
    }
    public boolean isSongPlaying() {
        WebElement soundBar = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@data-testid='sound-bar-play']")));
        return soundBar.isDisplayed();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants