Grafi
Grafi
CC#
Created by Grafi on 8/15/2024 in #help
Selenium C# text retrieval
Not sure where the sript fails ``` string code = "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"; private readonly By goToPastedCodeInput = By.CssSelector("a.btn.-small"); private readonly By pastedCodeInput = By.CssSelector("pre"); public string GetPastedCodeInput() { Driver.FindElement(goToPastedCodeInput).Click(); return Driver.FindElement(pastedCodeInput).Text; } string inputedCode = HomePage.GetPastedCodeInput(); Assert.IsTrue(inputedCode.Contains(code), $"Expected '{code}', but found '{inputedCode}'");
2 replies
CC#
Created by Grafi on 8/13/2024 in #help
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!
1 replies
CC#
Created by Grafi on 6/7/2024 in #help
LINQ
A sequence of non-empty strings of Latin alphabet characters stringList is given. Among all strings of the same length, sorted in ascending order, select the last character from each string, converting it to uppercase, and from the received characters, compose a string. Arrange the resulting sequence of strings in descending order of their lengths.
73 replies