RemoteLaunch with Python and Selenium

Wednesday, September 23, 2020
Avatar

Ok, so using the remote launch tool is a bit convoluted, but I finally got it successfully executing a remote script.

A simple test, such as executing a python script that prints something on the remote system reports back to spiratest as expected.

Next up was executing a very simple selenium test. The test opens a page, puts test into the search field, searches, and looks for a result. The script works fine when i execute it manually. When I execute it via RemoteLaunch, it runs the script, but the Selenium component does not seem to happen, and I get no feedback as to why.  I SHOULD see a commandline window come up, chrome launch, webpage change, chrome close, test complete. Instead I see the commandline window show up, print out my debug statements, and close Chrome never opens.

I am not using the selenium specific component of Spiratest. For now, I am attempting to deal strictly with executing my own scripts.

 

print("This line will be printed.")

import unittest

import time

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

time.sleep(3)
print("naptime over.")
class PythonOrgSearch(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Chrome()

    def test_search_in_python_org(self):
        driver = self.driver
        driver.get("https://mytestsite.com/jira/secure/Dashboard.jspa")
        self.assertIn("Jira", driver.title)
        elem = driver.find_element_by_name("searchString")
        elem.send_keys("username")
        elem.send_keys(Keys.RETURN)
        assert "No results found." not in driver.page_source


    def tearDown(self):
        self.driver.quit()
print("Ending the testcase.")

if __name__ == "__main__":
    unittest.main()

 

2 Replies
Wednesday, September 23, 2020
Avatar
re: oliverj Wednesday, September 23, 2020

Mods! I seem to have put this in the wrong section, my apologies.

Thursday, September 24, 2020
Avatar
re: oliverj Wednesday, September 23, 2020

It's fine. I would log a support ticket if you want specific help from our team

In general, RemoteLaunch and the command line parses the output text for a matching Regex to see if it passed or failed.

If you are using Python and its unit test framework, you might want to use our plugin for PyUnit or PyTest instead:

https://www.inflectra.com/SpiraTest/Downloads.aspx#TestAutomation

Regards

David

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Wednesday, September 23, 2020
  • Last Reply: Thursday, September 24, 2020
  • Replies: 2
  • Views: 4050