OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to publish results in Testrail with pytest and trcli in Python Selenium

  • Thread starter Thread starter T Stefan
  • Start date Start date
T

T Stefan

Guest
Recently I started a project - as a beginner - to automate the manual testing for a small web application, and after a lot of work I reached the point where I'm stuck when I want to publish the test results in Testrail. I've searched a lot on the internet, but I found some code examples written only for specific context that I don't understand.

So I've installed the pytest and trcli, but after the test is finished, the results are not published in the Testrail, and I don' know what I'm missing and what I need more in order to publish the results in Testrail as Pass/Fail.

The code I'm running (the script is run with a parameter, ex: testscript.py user8):

Code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.common.exceptions import NoSuchElementException
from pytest_testrail.plugin import testrail, pytestrail
from selenium.webdriver.common.by import By
from . import g_access
import time

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--incognito")
ServiceObj = Service('C:\Python\chrome_driver\chromedriver.exe')
driver = webdriver.Chrome(service = ServiceObj, options = chrome_options)
driver.maximize_window()

@pytestrail.case('C24965591')
def login_func():

    if g_access.arg_c in g_access.user_dict:

        driver.get(g_access.SttHomePage); time.sleep(3)
        driver.find_element(By.XPATH, g_access.username_field).send_keys(g_access.user_dict[g_access.arg_c][0]); time.sleep(1)
        driver.find_element(By.XPATH, g_access.MicrosoftNext).click(); time.sleep(5)
        driver.find_element(By.XPATH, g_access.keep_signed_in).click; time.sleep(1)
        driver.find_element(By.XPATH, g_access.EANext).click(); time.sleep(18)
        driver.find_element(By.XPATH, g_access.password_field).send_keys(g_access.user_dict[g_access.arg_c][1]); time.sleep(1)
        driver.find_element(By.XPATH, g_access.EAVerify).click(); time.sleep(7)

        expected_elm = driver.find_element(By.XPATH, g_access.homepage_msg)

        try:
            assert expected_elm.text == "Wellcome!"; print("Assertion Passed")
        except AssertionError:
            print("Assertion Failed")
            pass

The issue is that I don't know what I need in order to publish successfully the Pass or Fail results to testcases in the testrun
<p>Recently I started a project - as a beginner - to automate the manual testing for a small web application, and after a lot of work I reached the point where I'm stuck when I want to publish the test results in Testrail. I've searched a lot on the internet, but I found some code examples written only for specific context that I don't understand.</p>
<p>So I've installed the pytest and trcli, but after the test is finished, the results are not published in the Testrail, and I don' know what I'm missing and what I need more in order to publish the results in Testrail as Pass/Fail.</p>
<p>The code I'm running (the script is run with a parameter, ex: testscript.py user8):</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.common.exceptions import NoSuchElementException
from pytest_testrail.plugin import testrail, pytestrail
from selenium.webdriver.common.by import By
from . import g_access
import time

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--incognito")
ServiceObj = Service('C:\Python\chrome_driver\chromedriver.exe')
driver = webdriver.Chrome(service = ServiceObj, options = chrome_options)
driver.maximize_window()

@pytestrail.case('C24965591')
def login_func():

if g_access.arg_c in g_access.user_dict:

driver.get(g_access.SttHomePage); time.sleep(3)
driver.find_element(By.XPATH, g_access.username_field).send_keys(g_access.user_dict[g_access.arg_c][0]); time.sleep(1)
driver.find_element(By.XPATH, g_access.MicrosoftNext).click(); time.sleep(5)
driver.find_element(By.XPATH, g_access.keep_signed_in).click; time.sleep(1)
driver.find_element(By.XPATH, g_access.EANext).click(); time.sleep(18)
driver.find_element(By.XPATH, g_access.password_field).send_keys(g_access.user_dict[g_access.arg_c][1]); time.sleep(1)
driver.find_element(By.XPATH, g_access.EAVerify).click(); time.sleep(7)

expected_elm = driver.find_element(By.XPATH, g_access.homepage_msg)

try:
assert expected_elm.text == "Wellcome!"; print("Assertion Passed")
except AssertionError:
print("Assertion Failed")
pass
</code></pre>
<p>The issue is that I don't know what I need in order to publish successfully the Pass or Fail results to testcases in the testrun</p>
 
Top