174 lines
6.3 KiB
C#
174 lines
6.3 KiB
C#
using OpenQA.Selenium;
|
||
|
||
namespace TestProject
|
||
{
|
||
public class HomePage : BasePage
|
||
{
|
||
private By AuthLink = By.XPath("//a[@href='/ru/entrance']");
|
||
private By showMoreButton = By.XPath("//button[contains(@class, 'button___xFkMg') and contains(., 'Показать еще варианты')]");
|
||
private By emailAuthButton = By.XPath("//div[contains(@class, 'normal___w8_y9')]//a[contains(@href, '/ru/entrance/signin')]");
|
||
private By emailInput = By.XPath("//input[@name='email']");
|
||
private By passwordInput = By.XPath("//input[@name='password']");
|
||
private By submitButton = By.XPath("//button[@type='submit']//div[contains(@class, 'caption___L78vz') and contains(., 'Войти')]");
|
||
|
||
private By profileButton = By.XPath("//button[contains(@class, 'button___BfISQ')]//div[contains(@class, 'text___lAaAj') and contains(text(), 'Профиль')]");
|
||
private By reviewsLink = By.XPath("//a[contains(@class, 'item___tZDUe clickable___Yuycq largeText___H5mAO') and contains(text(), 'Мои обзоры')]");
|
||
|
||
private By editButton = By.XPath("//button[@testid='SocialUserEditButton']");
|
||
private By descriptionTextarea = By.XPath("//textarea[@name='description']");
|
||
private By saveButton = By.XPath("//button[@testid='SocialUserProfilePopupSubmitButton']");
|
||
|
||
private By ordersLink = By.XPath("//a[contains(@href, '/ru/orders')]");
|
||
private By balanceLink = By.XPath("//a[contains(@class, 'item___tZDUe clickable___Yuycq largeText___H5mAO') and contains(text(), 'Мой баланс')]");
|
||
|
||
private By searchInput = By.ClassName("input___OsSf0");
|
||
private By searchButton = By.ClassName("submitButton___iZDz3");
|
||
|
||
private By sortButton = By.XPath("//button[contains(@class, 'content___hcPVc') and contains(., 'Cортировка')]");
|
||
private By sortByPriceAscending = By.XPath("//a[contains(@href, '/s.origPrice.asc')]");
|
||
|
||
private By filterButton = By.XPath("//button[contains(@class, 'content___hcPVc') and contains(., 'Цена')]");
|
||
private By minPriceInput = By.XPath("//input[@name='min']");
|
||
private By maxPriceInput = By.XPath("//input[@name='max']");
|
||
private By applyFilterButton = By.XPath("//button[contains(@class, 'button___HN4kv') and contains(., 'Применить')]");
|
||
|
||
private By heartButton = By.XPath("//div[@class='actionButton___tq_Iy active___Rc9Go']//div[contains(@class, 'favoriteButton___z3oh3')]");
|
||
private By heartDeleteButton = By.XPath("//svg[@class='root___Z1kvz filled___PLueY']");
|
||
private By favoritesLink = By.XPath("//a[@href='/ru/favorites']");
|
||
|
||
private By productItem = By.XPath("//div[contains(@class, 'name___asFfu') and contains(., '25 игл из нержавеющей стали с большим ушком для вышивания')]");
|
||
private By addToCart = By.XPath("//span[contains(@class, 'label___CQCKv') and contains(., 'В корзину')]");
|
||
private By cartButton = By.XPath("//a[@href='/ru/cart']");
|
||
|
||
private By AddCountToCart = By.XPath("//button[@class='increase___T5SMf']");
|
||
private By deleteButton = By.XPath("//button[contains(@class, 'trash___gQVfp color-placeholder___eHEn5')]");
|
||
private By confirmDeleteButton = By.XPath("//button[contains(@class, 'button___Fogz2 rounded-rect___bviwL medium___fKhsq accent___SFpoh medium___fKhsq fullWidth___YCBfX')]");
|
||
|
||
public HomePage(IWebDriver driver) : base(driver) { }
|
||
|
||
public void Open()
|
||
{
|
||
OpenUrl("https://www.joom.ru/");
|
||
}
|
||
|
||
public void Auth(string email, string password)
|
||
{
|
||
Click(AuthLink);
|
||
Click(showMoreButton);
|
||
Click(emailAuthButton);
|
||
Type(emailInput, email);
|
||
Type(passwordInput, password);
|
||
Click(submitButton);
|
||
Thread.Sleep(5000);
|
||
}
|
||
|
||
public void AuthMy()
|
||
{
|
||
Auth("ЛОГИН", "ПАРОЛЬ");
|
||
}
|
||
|
||
public void EditAboutMe(string newDescription)
|
||
{
|
||
AuthMy();
|
||
Click(profileButton);
|
||
Click(reviewsLink);
|
||
Click(editButton);
|
||
FindElement(descriptionTextarea).Clear();
|
||
Type(descriptionTextarea, newDescription);
|
||
Click(saveButton);
|
||
}
|
||
|
||
public void ChechMyOrders()
|
||
{
|
||
AuthMy();
|
||
Click(ordersLink);
|
||
}
|
||
|
||
public void ChechMyFavorites()
|
||
{
|
||
AuthMy();
|
||
Click(profileButton);
|
||
Click(favoritesLink);
|
||
}
|
||
|
||
public void CheckMyBalance()
|
||
{
|
||
AuthMy();
|
||
Click(profileButton);
|
||
Click(balanceLink);
|
||
}
|
||
|
||
public void SearchForProduct(string productName)
|
||
{
|
||
Type(searchInput, productName);
|
||
Click(searchButton);
|
||
}
|
||
|
||
public void SortByPriceAscending()
|
||
{
|
||
Click(sortButton);
|
||
Click(sortByPriceAscending);
|
||
}
|
||
|
||
public void FilterByPrice(int minPrice, int maxPrice)
|
||
{
|
||
Click(filterButton);
|
||
Type(minPriceInput, minPrice.ToString());
|
||
Type(maxPriceInput, maxPrice.ToString());
|
||
Click(applyFilterButton);
|
||
}
|
||
|
||
public void AddFavorites(string productName)
|
||
{
|
||
AuthMy();
|
||
|
||
Type(searchInput, productName);
|
||
Click(searchButton);
|
||
|
||
Click(heartButton);
|
||
Click(profileButton);
|
||
Click(favoritesLink);
|
||
|
||
}
|
||
|
||
public void DeleteFavorites()
|
||
{
|
||
AuthMy();
|
||
|
||
Click(profileButton);
|
||
Click(favoritesLink);
|
||
Click(heartButton);
|
||
|
||
driver.Navigate().Refresh();
|
||
Thread.Sleep(5000);
|
||
}
|
||
|
||
public void AddToCart()
|
||
{
|
||
AuthMy();
|
||
|
||
OpenUrl("https://www.joom.ru/ru/products/645ba6bfc5f80701f93cead6?variant_id=645ba6bfc5f8072cf93cead8");
|
||
Thread.Sleep(3000);
|
||
Click(addToCart);
|
||
Click(cartButton);
|
||
}
|
||
|
||
public void UpdateCountProduct()
|
||
{
|
||
AuthMy();
|
||
|
||
Click(cartButton);
|
||
Click(AddCountToCart);
|
||
}
|
||
|
||
public void DeleteProductToCart()
|
||
{
|
||
AuthMy();
|
||
|
||
Click(cartButton);
|
||
Click(deleteButton);
|
||
Click(confirmDeleteButton);
|
||
}
|
||
}
|
||
}
|