मैंने अलग-अलग ओएस और ब्राउज़र वाले कई मशीनों में अपने पायथन परीक्षण चलाने के लिए सेलेनियम ग्रिड को सफलतापूर्वक स्थापित किया है। हालांकि, मुझे अभी भी एक ही टेस्ट केस 3 बार लिखना है, एक बार प्रत्येक नोड के लिए, क्योंकि नोड का संदर्भ टेस्ट केस के अंदर है।मैं एकाधिक मशीनों में परीक्षण करने के लिए सेलेनियम ग्रिड पायथन परीक्षण केस कैसे स्थापित करूं?
मैंने पाइथन उदाहरण के लिए ऑनलाइन सुझावों के सभी प्रकारों को देखा है। पृथक नोड ips बाहरी फाइलों में बाहर निकलते हैं और इसे परीक्षण मामले में आयात करते हैं लेकिन उनमें से कोई भी काम नहीं करता है या निर्देश जावा के लिए हैं।
मोज़िला से एक के साथ, मुझे यकीन है कि कैसे मैं अपने परीक्षण के मामलों के साथ इस फाइल को सेट अप नहीं कर रहा हूँ/यह कैसे चलाने के लिए: http://viewvc.svn.mozilla.org/vc/projects/sumo/tests/frontend/python_tests/suite_sumo.py?view=markup
मैं अपने अजगर परीक्षण मामलों की स्थापना करते हैं तो मैं केवल इसे लिखने एक बार?
मेरे हब कमांड प्रॉम्प्ट अनुदेश है:
java -jar selenium-server-standalone-2.29.0.jar -host http://localmachineipaddress -port 4444 -role hub
मेरे नोड्स कमांड प्रॉम्प्ट निर्देश हैं:
*FireFox PC, Chrome PC, Safari PC, and IE9 PC on local machine*
java -jar selenium-server-standalone-2.29.0.jar -host localhost -role webdriver -hub http://theHubIP:4444/grid/register -port 5555 -browser browserName=firefox,maxInstances=5,platform=WINDOWS -browser browserName=chrome,maxInstances=5,platform=WINDOWS -Dwebdriver.chrome.driver=c:\SeleniumGrid\chromedriver.exe -browser browserName=iehta,maxInstances=5,platform=WINDOWS -Dwebdriver.ie.driver=c:\SeleniumGrid\IEDriverServer.exe -browser browserName=safari,maxInstances=5,platform=WINDOWS -Dwebdriver.safari.driver=c:\Python27\SafariDriver2.28.0.safariextz
*FireFox MAC, Safari MAC, and Chrome MAC machine*
java -jar selenium-server-standalone-2.29.0.jar -role webdriver -hub http://theHubIP:4444/grid/register -debug -port 5556 -browser browserName=firefox,maxInstances=5,platform=MAC -browser browserName=chrome,maxInstances=5,platform=MAC -browser browserName=safari,maxInstances=5,platform=MAC -Dwebdriver.safari.driver=c:\Python27\SafariDriver2.28.0.safariextz
*IE8 PC machine*
java -jar selenium-server-standalone-2.29.0.jar -role webdriver -hub http://theHubIP:4444/grid/register -port 5559 -browser browserName=iehta,maxInstances=5,platform=WINDOWS -Dwebdriver.ie.driver=c:\SeleniumGrid\IEDriverServer.exe
मेरे टेस्ट केस कमांड प्रॉम्प्ट निर्देश हैं:
python Python27/Test_Cases/SeleniumTest.py 5555 firefox WINDOWS
python Python27/Test_Cases/SeleniumTest.py 5555 chrome WINDOWS
python Python27/Test_Cases/SeleniumTest.py 5555 iehta WINDOWS
python Python27/Test_Cases/SeleniumTest.py 5555 safari WINDOWS
python Python27/Test_Cases/SeleniumTestIE8.py 5559 iehta WINDOWS
python Python27/Test_Cases/SeleniumTestApple.py 5556 chrome MAC
python Python27/Test_Cases/SeleniumTestApple.py 5556 firefox MAC
python Python27/Test_Cases/SeleniumTestApple.py 5556 safari MAC
मेरे टेस्ट केस है: अपने अजगर स्क्रिप्ट
# coding: utf-8
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import HTMLTestRunner
import unittest, time
import sys
class SeleniumTest1(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Remote(command_executor="http://theNodeIP:5555/wd/hub",desired_capabilities={ "browserName": browser, "platform": platform, "node":node })
self.driver.implicitly_wait(2)
def mytest(self):
self.driver.get("http://url.com")
self.driver.find_element_by_css_xpath("test_some_stuff").click()
def tearDown(self):
self.driver.quit()
def suite():
s1 = unittest.TestLoader().loadTestsFromTestCase(SeleniumTest1)
return unittest.TestSuite([s1])
def run(suite, report = "C:\\Python27\\Test_Cases\\Reports\\SeleniumTest1.html"):
with open(report, "w") as f:
HTMLTestRunner.HTMLTestRunner(
stream = f,
title = 'SeleniumTest1',
verbosity = 2,
description = 'SeleniumTest1'
).run(suite)
if __name__ == "__main__":
args = sys.argv
node=args[1]
browser = args[2]
platform = args[3]
run(suite())
क्यों न केवल दोहराए गए टेस्ट कोड को फ़ंक्शन में डालें defRepeatTest (webdriver) को परिभाषित करें: # आपकी कोड लाइनें यहां जाती हैं ... –