Skip to content

Instantly share code, notes, and snippets.

View testingplusme's full-sized avatar

Michał testingplusme

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp1
{
public class Person
{
const string peselNumber = "number_pesel";
private int age;
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using SeleniumExtras.WaitHelpers;
namespace TestContentFromPdf.Extension
{
public static class WaitExtension
{
private static WebDriverWait wait;
using System;
namespace TestContentFromPdf.Extension
{
public class TestSettings
{
public static string PathToDownloads => $"{Environment.CurrentDirectory}/Downloads";
}
}
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace TestContentFromPdf.Extension
{
public class BaseTest : IDisposable
{
protected IWebDriver driver;
using System.IO;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using OpenQA.Selenium;
namespace TestContentFromPdf.Extension
{
public static class SeleniumExtension
{
@testingplusme
testingplusme / HomePage.cs
Created March 14, 2019 09:26
HomePage.cs
using System.Linq;
using OpenQA.Selenium;
namespace TestContentFromPdf.Pages
{
public class HomePage
{
public By FirstAvailableLinkToDocument => By.CssSelector("td a:nth-child(4)");
private IWebDriver driver;
using Shouldly;
using TestContentFromPdf.Extension;
using TestContentFromPdf.Pages;
using Xunit;
namespace TestContentFromPdf.Tests
{
public class TestContentFromPdf : BaseTest
{
[Fact]
[AfterScenario]
public void AfterScenario()
{
var driver = container.Resolve<IWebDriver>() as RemoteWebDriver;
if (scenarioContext.TestError!=null)
allureReport.AddVideoToScenario(scenarioContext.ScenarioInfo.Title, driver.SessionId.ToString());
driver.Quit();
container.Dispose();
}
[AfterStep]
public void AfterStep()
{
if (scenarioContext.TestError != null)
allureReport.SaveScreenshot(Guid.NewGuid().ToString(),scenarioContext.StepContext.StepInfo.Text);
}
public void SaveScreenshot(string title, string step)
{
try
{
var path = $"{TestConfiguration.DirectoryPath}\\{title}{DateTime.Now:HH}";
Directory.CreateDirectory(path);
var pathToFile = $"{path}\\{CleanFileName(DateTime.UtcNow.ToLongTimeString())}.png";
if (scenarioContext.TestError != null)
{
var errorPath = $"{path}\\errors\\";