Reputation: 11
Code:
[TestFixture]
public class CETestsActionDev
{
private IWebDriver driver;
private readonly string environment = "dev";
private static int _randomNumber;
[SetUp]
public void Setup()
{
//They re commented because if not, code in gbActions doesnt find even "userName"
//ChromeOptions options = new();
//options.AddArgument("start-maximized");
//options.AddArgument("--disable-gpu");
//options.AddArgument("--headless");
driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
}
[Test]
public void SuccessCloudExpertProfile()
{
Thread.Sleep(TimeSpan.FromSeconds(5));
driver.Navigate().GoToUrl("https:comapnyExemplo.com");
Thread.Sleep(TimeSpan.FromSeconds(10));
string emailDev = "[email protected]";
driver.FindElement(By.XPath("//*[@id='userName']")).SendKeys(emailDev);
driver.FindElement(By.XPath("//*[@id='password']")).SendKeys("testCloud2Gether");
Thread.Sleep(TimeSpan.FromSeconds(1));
driver.FindElement(By.XPath("//*[@id='buttonForm']")).Click();
Thread.Sleep(TimeSpan.FromSeconds(10));
AddPublicNameAndAboutField(driver);
//First xpath from this method is "name"
AddLanguages(driver);
RemoveLanguages(driver);
CorrectAdress(driver);
}
GitHub Actions Yaml: Test_Project_Path: C2GSeleniumTeste.csproj
steps:
name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0
name: Install .NET Core uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x
name: Install Chrome uses: browser-actions/setup-chrome@v1 with: chrome-version: 'stable'
name: Restore dependencies run: dotnet restore ${{ env.Test_Project_Path }}
name: Run tests run: dotnet test ${{ env.Test_Project_Path }} --configuration Release --logger trx --results-directory .
name: Upload test results if: failure() uses: actions/upload-artifact@v3 with: name: test-results path: '*.trx' if-no-files-found: warn
I want to run selenium code in GithubActions but im not having success
Upvotes: 0
Views: 57
Reputation: 11
When the tests were running in GitHub Actions, the reCAPTCHA was activated.
Upvotes: 1