<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: DelRayo</title>
    <description>The latest articles on Forem by DelRayo (@delrayo).</description>
    <link>https://forem.com/delrayo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F783311%2F7f161696-7c47-4b97-8dae-574be2ca3527.png</url>
      <title>Forem: DelRayo</title>
      <link>https://forem.com/delrayo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/delrayo"/>
    <language>en</language>
    <item>
      <title>Executing Selenium test with python(pytest) using GitHub Actions</title>
      <dc:creator>DelRayo</dc:creator>
      <pubDate>Thu, 13 Jan 2022 04:22:09 +0000</pubDate>
      <link>https://forem.com/delrayo/executing-selenium-test-with-pythonpytest-using-github-actions-317c</link>
      <guid>https://forem.com/delrayo/executing-selenium-test-with-pythonpytest-using-github-actions-317c</guid>
      <description>&lt;p&gt;&lt;a href="delrayo.tech"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmeud6c5og1dh3xvbebp.png" alt="DelRayo.tech" width="800" height="404"&gt;&lt;/a&gt;&lt;br&gt;
You can find the working project &lt;a href="https://github.com/delrayo/Pytest-Selenium-GitHubActions" rel="noopener noreferrer"&gt;Here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First we are going to create some example tests.&lt;br&gt;
I'll be using selenium with python(pytest).&lt;/p&gt;

&lt;p&gt;So for this example ill be creating 2 files one will be called &lt;strong&gt;conftest.py&lt;/strong&gt; and the second one will be &lt;strong&gt;test_web01.py&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/delrayo/Pytest-Selenium-GitHubActions/blob/main/conftest.py" rel="noopener noreferrer"&gt;conftest.py in GitHub&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pytest
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
from selenium import webdriver


@pytest.fixture()
def setup(request):
    chrome_service = Service(ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install())

    chrome_options = Options()
    options = [
    "--headless",
    "--disable-gpu",
    "--window-size=1920,1200",
    "--ignore-certificate-errors",
    "--disable-extensions",
    "--no-sandbox",
    "--disable-dev-shm-usage"
]
    for option in options:
        chrome_options.add_argument(option)

    request.cls.driver = webdriver.Chrome(service=chrome_service, options=chrome_options)


    yield request.cls.driver
    request.cls.driver.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now lets create the second file where the actual tests are. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/delrayo/Pytest-Selenium-GitHubActions/blob/main/test_web01.py" rel="noopener noreferrer"&gt;test_web01.py in GitHub&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pytest


@pytest.mark.usefixtures("setup")
class TestExampleOne:
    def test_title(self):
        self.driver.get('https://www.delrayo.tech')
        assert self.driver.title == "DelRayo.tech - Delrayo Tech"

    def test_title_blog(self):
        self.driver.get('https://www.delrayo.tech/blog')
        print(self.driver.title)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For running with GithubActions we have to create the following file structure on the repo.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;-.github&lt;/li&gt;
&lt;li&gt;--workflows&lt;/li&gt;
&lt;li&gt;---test01.yaml&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/delrayo/Pytest-Selenium-GitHubActions/blob/main/.github/workflows/test01.yml" rel="noopener noreferrer"&gt;test01.yaml in GitHub&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# .github/workflows/test01.yaml
name: test01
on:
  workflow_dispatch:  
jobs:
  test01:
    runs-on: ubuntu-latest
    steps:
      - name: Check out this repo
        uses: actions/checkout@v2
     #Setup Python   
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.9'
      - name: Install software
        run: sudo apt-get install -y chromium-browser
      - name: Install the necessary packages
        run: pip install requests webdriver-manager selenium pytest
      - name: Run the PytTest script
        run: pytest -rA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we just have to go to the actions section on github, select the workflow named test01 and click on the button run workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqjgur61nreucendrmqrv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqjgur61nreucendrmqrv.png" alt="GitHub Actions" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can configure this workflow to execute on different triggers modifying&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
on:
  workflow_dispatch:  

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With any of these &lt;a href="https://docs.github.com/es/actions/learn-github-actions/events-that-trigger-workflows" rel="noopener noreferrer"&gt;options&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7jap1twkeqphe6l7rzn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7jap1twkeqphe6l7rzn.png" alt="Test Pass with GitHub Actions" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the working project &lt;a href="https://github.com/delrayo/Pytest-Selenium-GitHubActions" rel="noopener noreferrer"&gt;Here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>github</category>
      <category>sdet</category>
      <category>python</category>
      <category>selenium</category>
    </item>
    <item>
      <title>Swipe objects in Appium with C#</title>
      <dc:creator>DelRayo</dc:creator>
      <pubDate>Mon, 03 Jan 2022 19:37:33 +0000</pubDate>
      <link>https://forem.com/delrayo/swipe-objects-in-appium-with-c-18kc</link>
      <guid>https://forem.com/delrayo/swipe-objects-in-appium-with-c-18kc</guid>
      <description>&lt;p&gt;Simple function for swiping object 1 to object 2 in Appium using C#&lt;/p&gt;

&lt;p&gt;Swipe objects in appium using W3C standards in C#&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/delrayo/swiping_appium_c-/blob/main/swipe.cs" rel="noopener noreferrer"&gt;https://github.com/delrayo/swiping_appium_c-/blob/main/swipe.cs&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// this code works Following the W3C standards

using System.Threading;
using OpenQA.Selenium.Appium.MultiTouch;

float object1CoordinateX = 500;
float object1CoordinateY = 500;
float object2CoordinateX = 500;
float object2CoordinateY = 1000;

TouchAction actionOne = new TouchAction((OpenQA.Selenium.Appium.Interfaces.IPerformsTouchActions)TestData.driver);
actionOne.Press(object1CoordinateX, object1CoordinateY);
actionOne.MoveTo(object2CoordinateX, object2CoordinateY);
actionOne.Release();
actionOne.Perform();
Thread.Sleep(2500);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://delrayo.tech/blog/post/1634195/swipe-appium-csharp" rel="noopener noreferrer"&gt;https://delrayo.tech/blog/post/1634195/swipe-appium-csharp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.DelRayo.tech" rel="noopener noreferrer"&gt;https://www.DelRayo.tech&lt;/a&gt; &lt;/p&gt;

</description>
      <category>csharp</category>
      <category>appium</category>
      <category>qa</category>
      <category>sdet</category>
    </item>
    <item>
      <title>Creating a Selenium grid with Docker Compose and run python tests.</title>
      <dc:creator>DelRayo</dc:creator>
      <pubDate>Thu, 30 Dec 2021 20:19:38 +0000</pubDate>
      <link>https://forem.com/delrayo/creating-a-selenium-grid-with-docker-compose-and-run-python-tests-17n3</link>
      <guid>https://forem.com/delrayo/creating-a-selenium-grid-with-docker-compose-and-run-python-tests-17n3</guid>
      <description>&lt;p&gt;We are going to use docker compose for creating a Selenium grid and run some basic python tests against the grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjx26qu5ksgjg0whzfd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjx26qu5ksgjg0whzfd7.png" alt="Image description" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always the files can be found on &lt;a href="https://github.com/delrayo/DockerComposeSeleniumGrid" rel="noopener noreferrer"&gt;GitHub &lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download the repo, &lt;/li&gt;
&lt;li&gt;Open a terminal in the repo folder&lt;/li&gt;
&lt;li&gt;Execute "docker-compose up -d".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flwe88vsj07ys1jrpwaft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flwe88vsj07ys1jrpwaft.png" alt="Image description" width="641" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That will spin up the grid, when docker finish preparing your grid you should go to &lt;a href="http://localhost:4444/grid/console" rel="noopener noreferrer"&gt;http://localhost:4444/grid/console&lt;/a&gt;  just to verify that everything is ok.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjr8q4z549wkslu63q43i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjr8q4z549wkslu63q43i.png" alt="Image description" width="800" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then just run a simple test against this grid. &lt;br&gt;
For doing this you should create a new selenium driver pointing to the grid, if you are using python is something like this for chrome :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver = webdriver.Remote(
   command_executor="http://127.0.0.1:4444/wd/hub",
   desired_capabilities={
            "browserName": "chrome",
        })

driver1 = webdriver.Remote(
   command_executor="http://127.0.0.1:4444/wd/hub",
   desired_capabilities={
            "browserName": "chrome",
        })

driver2 = webdriver.Remote(
   command_executor="http://127.0.0.1:4444/wd/hub",
   desired_capabilities={
            "browserName": "chrome",
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find a test example file in &lt;a href="https://github.com/delrayo/DockerComposeSeleniumGrid/blob/main/test.py" rel="noopener noreferrer"&gt;https://github.com/delrayo/DockerComposeSeleniumGrid/blob/main/test.py&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps you on your testing.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>selenium</category>
      <category>sdet</category>
      <category>python</category>
    </item>
  </channel>
</rss>
