Skip to content

Instantly share code, notes, and snippets.

View testingplusme's full-sized avatar

Michał testingplusme

View GitHub Profile
node {
stage 'Checkout'
checkout scm
stage 'Build'
public string VideoInHtml(string sessionId)
{
//Place where you put url address to Selenoid
var html = $"<html><body><video width=\'100%\' height=\'100%\' controls autoplay><source src=\'http://addressToYourSelenoid:4444/video/{sessionId}.mp4' type=\'video/mp4\'></video></body></html>";
return html;
}
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\\";
[AfterStep]
public void AfterStep()
{
if (scenarioContext.TestError != null)
allureReport.SaveScreenshot(Guid.NewGuid().ToString(),scenarioContext.StepContext.StepInfo.Text);
}
[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();
}
using Shouldly;
using TestContentFromPdf.Extension;
using TestContentFromPdf.Pages;
using Xunit;
namespace TestContentFromPdf.Tests
{
public class TestContentFromPdf : BaseTest
{
[Fact]
@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 System.IO;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using OpenQA.Selenium;
namespace TestContentFromPdf.Extension
{
public static class SeleniumExtension
{
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace TestContentFromPdf.Extension
{
public class BaseTest : IDisposable
{
protected IWebDriver driver;
using System;
namespace TestContentFromPdf.Extension
{
public class TestSettings
{
public static string PathToDownloads => $"{Environment.CurrentDirectory}/Downloads";
}
}