C
C#2mo ago
Grafi

Selenium WebDriver and NUnit Tests

The script itself works, the problem lies in testing this thing.
private readonly By selectedSyntaxDisplay = By.CssSelector(".select2-selection__rendered");
private readonly By pastedCodeInput = By.CssSelector("textarea - form js - paste - code");

public string GetSelectedSyntax()
{
return Driver.FindElement(selectedSyntaxDisplay).Text;
}

public string GetPastedCodeInput()
{
return Driver.FindElement(pastedCodeInput).Text;
}
private readonly By selectedSyntaxDisplay = By.CssSelector(".select2-selection__rendered");
private readonly By pastedCodeInput = By.CssSelector("textarea - form js - paste - code");

public string GetSelectedSyntax()
{
return Driver.FindElement(selectedSyntaxDisplay).Text;
}

public string GetPastedCodeInput()
{
return Driver.FindElement(pastedCodeInput).Text;
}
string selectedSyntax = HomePage.GetSelectedSyntax();
Assert.IsTrue(selectedSyntax.Contains("Bash"), $"Expected 'Bash', but found '{selectedSyntax}'");

string inputedCode = HomePage.GetPastedCodeInput();
Assert.IsTrue(inputedCode.Contains("git config --global user.name  \"New Sheriff in Town\"\r\ngit reset $(git commit-tree HEAD^{tree} -m \"Legacy code\")\r\ngit push origin master --force\r\n"),
$"Expected 'git config --global user.name  \"New Sheriff in Town\"\r\ngit reset $(git commit-tree HEAD^{{tree}} -m \"Legacy code\")\r\ngit push origin master --force\r\n', but found '{inputedCode}'");
string selectedSyntax = HomePage.GetSelectedSyntax();
Assert.IsTrue(selectedSyntax.Contains("Bash"), $"Expected 'Bash', but found '{selectedSyntax}'");

string inputedCode = HomePage.GetPastedCodeInput();
Assert.IsTrue(inputedCode.Contains("git config --global user.name  \"New Sheriff in Town\"\r\ngit reset $(git commit-tree HEAD^{tree} -m \"Legacy code\")\r\ngit push origin master --force\r\n"),
$"Expected 'git config --global user.name  \"New Sheriff in Town\"\r\ngit reset $(git commit-tree HEAD^{{tree}} -m \"Legacy code\")\r\ngit push origin master --force\r\n', but found '{inputedCode}'");
I think it's because the tests check for unselected boxes but im not sure. Any one with ideas is welcomed!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server