Revize d65e75d9
Přidáno uživatelem Jakub Schenk před téměř 3 roky(ů)
Backend/Backend.sln | ||
---|---|---|
11 | 11 |
EndProject |
12 | 12 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BackendTesting", "BackendTesting\BackendTesting.csproj", "{516D3F60-5760-445B-9B0C-B2108046D9D4}" |
13 | 13 |
EndProject |
14 |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontendTesting", "FrontendTesting\FrontendTesting.csproj", "{1C3F4C13-1E04-4E2A-A591-1F607A2D2E08}" |
|
15 |
EndProject |
|
14 | 16 |
Global |
15 | 17 |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
16 | 18 |
Debug|Any CPU = Debug|Any CPU |
... | ... | |
33 | 35 |
{516D3F60-5760-445B-9B0C-B2108046D9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU |
34 | 36 |
{516D3F60-5760-445B-9B0C-B2108046D9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU |
35 | 37 |
{516D3F60-5760-445B-9B0C-B2108046D9D4}.Release|Any CPU.Build.0 = Release|Any CPU |
38 |
{1C3F4C13-1E04-4E2A-A591-1F607A2D2E08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
39 |
{1C3F4C13-1E04-4E2A-A591-1F607A2D2E08}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
40 |
{1C3F4C13-1E04-4E2A-A591-1F607A2D2E08}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
41 |
{1C3F4C13-1E04-4E2A-A591-1F607A2D2E08}.Release|Any CPU.Build.0 = Release|Any CPU |
|
36 | 42 |
EndGlobalSection |
37 | 43 |
GlobalSection(SolutionProperties) = preSolution |
38 | 44 |
HideSolutionNode = FALSE |
Backend/FrontendTesting/FrontendTesting.csproj | ||
---|---|---|
1 |
<Project Sdk="Microsoft.NET.Sdk"> |
|
2 |
|
|
3 |
<PropertyGroup> |
|
4 |
<TargetFramework>net6.0</TargetFramework> |
|
5 |
<Nullable>enable</Nullable> |
|
6 |
|
|
7 |
<IsPackable>false</IsPackable> |
|
8 |
</PropertyGroup> |
|
9 |
|
|
10 |
<ItemGroup> |
|
11 |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> |
|
12 |
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" /> |
|
13 |
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" /> |
|
14 |
<PackageReference Include="coverlet.collector" Version="3.1.0" /> |
|
15 |
</ItemGroup> |
|
16 |
|
|
17 |
</Project> |
Backend/FrontendTesting/LoginTesting.cs | ||
---|---|---|
1 |
using System.Linq; |
|
2 |
using System.Text; |
|
3 |
using Microsoft.VisualStudio.TestTools.UnitTesting; |
|
4 |
using OpenQA.Selenium; |
|
5 |
using OpenQA.Selenium.Chrome; |
|
6 |
using OpenQA.Selenium.Firefox; |
|
7 |
|
|
8 |
using System; |
|
9 |
using System.Collections; |
|
10 |
using System.Collections.Generic; |
|
11 |
using System.Threading; |
|
12 |
|
|
13 |
|
|
14 |
namespace FrontendTesting |
|
15 |
{ |
|
16 |
public class LoginTesting |
|
17 |
{ |
|
18 |
public IWebDriver [] drivers = { new FirefoxDriver(), new ChromeDriver()}; |
|
19 |
public string url = ""; |
|
20 |
public By usernameField = By.Id(""); |
|
21 |
public By passwordField = By.Id(""); |
|
22 |
public By loginButton = By.Id(""); |
|
23 |
|
|
24 |
|
|
25 |
[TestMethod] |
|
26 |
[DataRow ("aaa", "aaa")] |
|
27 |
[DataRow("bbb", "bbb")] |
|
28 |
[DataRow("ccc", "ccc")] |
|
29 |
public void Login_Correct(string username, string password) |
|
30 |
{ |
|
31 |
foreach (IWebDriver driver in drivers) |
|
32 |
{ |
|
33 |
//prace s driverem |
|
34 |
driver.Manage().Window.Maximize(); |
|
35 |
driver.Navigate().GoToUrl(url); //zakladni stranka |
|
36 |
Thread.Sleep(250); |
|
37 |
|
|
38 |
driver.FindElement(usernameField).SendKeys(username); //odsouhlaseni coockies |
|
39 |
driver.FindElement(passwordField).SendKeys(password); //napsat Elden Ring do hledani |
|
40 |
driver.FindElement(loginButton).Click(); //kliknout na button pro poslani prikazu |
|
41 |
Thread.Sleep(250); |
|
42 |
//TODO - jsem spravne na jine strance a prihlasen? |
|
43 |
//find element username -> po prihlaseni v nav baru |
|
44 |
|
|
45 |
driver.Quit(); |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
[TestMethod] |
|
51 |
[DataRow("aaa", "abc")] |
|
52 |
[DataRow("bbb", "")] |
|
53 |
[DataRow("", "abc")] |
|
54 |
public void Login_Incorrect(string username, string password) |
|
55 |
{ |
|
56 |
foreach (IWebDriver driver in drivers) |
|
57 |
{ |
|
58 |
//prace s driverem |
|
59 |
driver.Manage().Window.Maximize(); |
|
60 |
driver.Navigate().GoToUrl(url); //zakladni stranka |
|
61 |
Thread.Sleep(250); |
|
62 |
|
|
63 |
driver.FindElement(usernameField).SendKeys(username); //odsouhlaseni coockies |
|
64 |
driver.FindElement(passwordField).SendKeys(password); //napsat Elden Ring do hledani |
|
65 |
driver.FindElement(loginButton).Click(); //kliknout na button pro poslani prikazu |
|
66 |
Thread.Sleep(250); |
|
67 |
|
|
68 |
//TODO - spadlo to? neprihlasil jsem se |
|
69 |
//find element chybova hlaska? - spravna chybova hlaska? |
|
70 |
|
|
71 |
driver.Quit(); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
} |
|
79 |
} |
Backend/FrontendTesting/UnitTest1.cs | ||
---|---|---|
1 |
using Microsoft.VisualStudio.TestTools.UnitTesting; |
|
2 |
|
|
3 |
namespace FrontendTesting |
|
4 |
{ |
|
5 |
[TestClass] |
|
6 |
public class UnitTest1 |
|
7 |
{ |
|
8 |
[TestMethod] |
|
9 |
public void TestMethod1() |
|
10 |
{ |
|
11 |
} |
|
12 |
} |
|
13 |
} |
Také k dispozici: Unified diff
Frontend testing
frontend testing base