This commit is contained in:
Lukáš Kaňka 2023-08-24 17:12:11 +02:00
parent 7634250751
commit bec7a83b2e
13 changed files with 69 additions and 25 deletions

View File

@ -16,29 +16,39 @@ namespace LukanPOM.PageObjects
{
public class HomePage
{
private IWebDriver _driver;
private IWebDriver driver;
[FindsBy(How = How.ClassName, Using = "eu-cookies-bar-tick")]
private IWebElement _clickcookieaccept;
[FindsBy(How = How.Id, Using = "menu-item-439")]
private IWebElement _clickzasadyochrany;
IWebElement ClickAcceptCookie => driver.FindElement(By.XPath("//div[2]/span"));
IWebElement ClickZasady => driver.FindElement(By.Id("menu-item-439"));
public HomePage(IWebDriver driver)
{
_driver = driver;
this.driver = driver;
}
public void AcceptCookie()
{
_clickcookieaccept.Click();
ClickAcceptCookie.Click();
}
public void ZasadyOchrany()
{
_clickzasadyochrany.Click();
ClickZasady.Click();
}
public void TitleTest()
{
}
}
}
}

View File

@ -0,0 +1,35 @@
using OpenQA.Selenium.Chrome;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using LukanPOM.PageObjects;
namespace LukanPOM.Common
{
internal class TestBase
{
public HomePage home { get; private set; }
protected IWebDriver Driver { get; private set; }
[SetUp]
public void Setup()
{
Driver = new ChromeDriver();
Driver.Manage().Window.Maximize();
Driver.Navigate().GoToUrl("https://lukan.cz");
Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
home = new HomePage(Driver);
}
[TearDown]
public void TearDown()
{
Driver.Quit();
}
}
}

View File

@ -14,28 +14,27 @@ using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;
using OpenQA.Selenium.Chrome;
using LukanPOM.PageObjects;
using LukanPOM.Common;
namespace LukanPOM.Tests
{
public class AcceptCookie
{
private IWebDriver? _driver;
[SetUp]
public void InitScript()
//private IWebDriver? _driver;
internal class HomePage : TestBase
{
new DriverManager().SetUpDriver(new ChromeConfig());
_driver = new ChromeDriver();
_driver.Manage().Window.Maximize();
}
[Test]
public void TestCookie()
[Test]
public void AcceptCookieTest()
{
HomePage hp = new HomePage(_driver);
_driver.Navigate().GoToUrl("https://lukan.cz");
hp.ZasadyOchrany();
home.AcceptCookie();
}
}
}

View File

@ -1 +1 @@
385966025
1695163839

View File

@ -1 +1 @@
63e5f0709ae68783c6bfd06ea17d01dfba94d2d4
cc6aed74361c6473bdc4ce34a0da9dfb4ecb0290