def record(path,rtime): #os.chdir(path) t = time.strftime("%Y_%m_%d") + time.strftime("_%H_%M_%S") c = Castro(filename = t + ".swf") c.init() c.start() print "Start recording--------" time.sleep(rtime) c.stop() return None
class VideoRecordingTests (unittest.TestCase) : def setUp(self) : # Create an instance of Castro and provide name for the output file self.screenCapture = Castro(filename="testGoogleSearch.swf") # Start the recording of movie self.screenCapture.start() self.driver = webdriver.Firefox() def testGoogleSearch(self) : driver = self.driver driver.get("http://www.google.com") inputElement = driver.find_element_by_name("q") inputElement.send_keys("Cheese!") inputElement.submit() WebDriverWait(driver, 20).until(lambda driver : driver.title.lower().startswith("cheese!")) self.assertEqual("cheese! - Google Search",driver.title) def tearDown(self) : self.driver.quit() # Stop the recording self.screenCapture.stop();
class VideoRecordingTests(unittest.TestCase): def setUp(self): # Create an instance of Castro and provide name for the output file self.screenCapture = Castro(filename="testGoogleSearch.swf") # Start the recording of movie self.screenCapture.start() self.driver = webdriver.Firefox() def testGoogleSearch(self): driver = self.driver driver.get("http://www.google.com") inputElement = driver.find_element_by_name("q") inputElement.send_keys("Cheese!") inputElement.submit() WebDriverWait(driver, 20).until( lambda driver: driver.title.lower().startswith("cheese!")) self.assertEqual("cheese! - Google Search", driver.title) def tearDown(self): self.driver.quit() # Stop the recording self.screenCapture.stop()
class SearchProductTest(unittest.TestCase): def setUp(self): # create an instance of Castro and provide name for the output file self.screenCapture = Castro(filename='testSearchByCategory.swf') # start the recording of movie self.screenCapture.start() # create a new Firefox session self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.driver.maximize_window() # navigate to the application home page self.driver.get('http://demo-store.seleniumacademy.com/') def test_search_by_category(self): # get the search textbox search_field = self.driver.find_element_by_name('q') search_field.clear() # enter search keyword and submit search_field.send_keys('phones') search_field.submit() # get all the anchor elements which have product names displayed # currently on result page using find_elements_by_xpath method products = self.driver.find_elements_by_xpath( "//h2[@class='product-name']/a") # check count of products shown in results self.assertEqual(2, len(products)) def tearDown(self): # close the browser window self.driver.quit() # Stop the recording self.screenCapture.stop()
class SearchProductTest(unittest.TestCase): def setUp(self): # create an instance of Castro and provide name for the output file self.screenCapture = Castro(filename="testSearchByCategory.swf") # start the recording of movie self.screenCapture.start() # create a new Firefox session self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.driver.maximize_window() # navigate to the application home page self.driver.get("http://demo.magentocommerce.com/") def test_search_by_category(self): # get the search textbox search_field = self.driver.find_element_by_name("q") search_field.clear() # enter search keyword and submit search_field.send_keys("phones") search_field.submit() # get all the anchor elements which have product names displayed # currently on result page using find_elements_by_xpath method products = self.driver.find_elements_by_xpath("//h2[@class='product-name']/a") # check count of products shown in results self.assertEqual(2, len(products)) def tearDown(self): # close the browser window self.driver.quit() # Stop the recording self.screenCapture.stop()
class SearchProductTest(unittest.TestCase): def setUp(self): # tạo ra 1 đối tượng (hay thể hiện) Castro và init nó self.screenCapture = Castro( filename='PYTHON/chapter_9/testSearchByCategory.swf') self.screenCapture.start() self.driver = webdriver.Chrome() self.driver.implicitly_wait(3) self.driver.maximize_window() self.driver.get('http://www.lazada.vn') def test_search_by_category(self): driver = self.driver self.search_field = driver.find_element_by_name('q') self.search_field.clear() self.search_field.send_keys('smartphone') self.search_field.submit() self.products = driver.find_elements_by_xpath("//div[@class='c2prKC']") self.assertEqual(40, len(self.products)) def tearDown(self): self.driver.quit() self.screenCapture.stop()
class DJHelpers(unittest.TestCase): def setUp(self): self.screenCapture = Castro(filename="createprofile.swf") self.screenCapture.start() #self.driver = webdriver.Firefox() self.driver = webdriver.Chrome('/Users/ian.griffith/chromedriver') self.driver.implicitly_wait(30) self.base_url = "http://stage-dj.beatport.com/" self.verificationErrors = [] self.generateData() def generateData(self): self.bio = " " self.driver = self.driver self.event = random.randrange(1,47000,1); self.profile = random.randrange(1,150000,1); self.random1 = random.randrange(2000,99999,1); self.photo = random.randrange(1,1043,1); self.photo2 = random.randrange(1,1043,1); self.photo5 = random.randrange(1,1043,1); self.rndgenre1 = random.randrange(1,23,1); self.rndgenre2 = random.randrange(1,23,1); self.rndgenre3 = random.randrange(1,23,1); self.rndgenre4 = random.randrange(1,23,1); self.rndgenre5 = random.randrange(1,23,1); self.rndgenre6 = random.randrange(1,23,1); self.dj1 = random.randrange(1,15,1); print str(self.dj1) print str(self.random1) print str(self.event) print str(self.photo) print str(self.photo2) print str(self.photo5) print str(self.profile) self.driver.get("http://dj.beatport.com/profile/" + str(self.profile)) self.profile_url = self.driver.current_url print(self.profile_url) self.djname = self.driver.find_element_by_css_selector("h1").text print(self.djname) #____________________________________________End Gathering Data__Begin registering def registerDJ(self, djname, random): driver=self.driver driver.get("http://stage-dj.beatport.com/") time.sleep(3) driver.get("https://stage-accounts.beatport.com/register") driver.find_element_by_id("first-name").clear() driver.find_element_by_id("first-name").send_keys(djname) driver.find_element_by_id("last-name").clear() driver.find_element_by_id("last-name").send_keys(djname) driver.find_element_by_id("emailAddress").clear() driver.find_element_by_id("emailAddress").send_keys("ian.griffith+" + str(self.random1) +"@beatport.com") driver.find_element_by_id("confirmEmailAddress").clear() driver.find_element_by_id("confirmEmailAddress").send_keys("ian.griffith+" + str(self.random1) +"@beatport.com") driver.find_element_by_id("username").clear() driver.find_element_by_id("username").send_keys("dj" + str(self.random1)) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys("beatport1") driver.find_element_by_id("confirmPassword").clear() driver.find_element_by_id("confirmPassword").send_keys("beatport1") #changed the submit button - was searching it by css-selector, i changed it to xpath driver.find_element_by_xpath("//button[@type=\"submit\"]").click() #_____________________________________________End registering account__begin create dj profile def createProfile(self, djname, random1, rndgenre1, rndgenre2, rndgenre3): time.sleep(2) driver=self.driver driver.get("http://stage-dj.beatport.com/") driver.switch_to_default_content() driver.find_element_by_id("logo").click() time.sleep(2) driver.find_element_by_xpath("//*[@id=\"header\"]/div/div[2]/ul/li[3]/a").click() driver.find_element_by_id("profile_name").clear() driver.find_element_by_id("profile_name").send_keys(djname) driver.find_element_by_id("profile_slug").clear() driver.find_element_by_id("profile_slug").send_keys(djname) + str(random1) driver.find_element_by_id("profile_bio").clear() driver.find_element_by_id("profile_bio").send_keys("dj" + str(random1) + " password beatport1 -------- " + self.bio) driver.find_element_by_id("profile_image").send_keys("/Users/ian.griffith/Desktop/numbered_djs/dj" + str(self.photo) + ".jpg") driver.find_element_by_xpath("//input[@value='Create Profile']").click() time.sleep(2) # ___create dj profile___Begin genres driver.find_element_by_xpath("//div[@id='genre-list']/ul/li[" + str(rndgenre1) + "]").click() driver.find_element_by_xpath("//div[@id='genre-list']/ul/li[" + str(rndgenre2) + "]").click() driver.find_element_by_xpath("//div[@id='genre-list']/ul/li[" + str(rndgenre3) + "]").click() time.sleep(2) # __create dj profile____begin management driver.find_element_by_link_text("Management").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("griffith1") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("sillyhat") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("blissriot") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("prldd") driver.find_element_by_xpath("//input[@value='Add Manager']").click() # I split off the video as a test self.driver.find_element_by_link_text("Videos").click() self.driver.find_element_by_id("video_url").clear() self.driver.find_element_by_id("video_url").send_keys("http://www.youtube.com/watch?v=IzgFXpZsLYA&feature=plcp") self.driver.find_element_by_xpath("//input[@value='Add Video']").click() def addVideo(self): driver=self.driver driver.find_element_by_id("video_url").click() driver.find_element_by_id("video_url").clear() driver.find_element_by_id("video_url").send_keys("http://www.youtube.com/watch?v=cHzhlJ48UjM&feature=plcp") driver.find_element_by_xpath("//input[@value='Add Video']").click() time.sleep(4) #___________create dj profile________begin Soundcloud add def addSoundCloud(self): self.driver.find_element_by_link_text("SoundCloud").click() self.driver.find_element_by_link_text("Individual Tracks").click() self.driver.find_element_by_id("soundcloud_track_url").clear() self.driver.find_element_by_id("soundcloud_track_url").send_keys("http://soundcloud.com/maisondragen/armin-van-buuren-we-are-here-to-make-some-noise-maison-dragen-remix-edit") self.driver.find_element_by_xpath("//input[@value='Add Track']").click() #............... End Create DJ Profile___ begin search/follow/unfollow def addSearchFollow(self): self.driver.get("http://stage-dj.beatport.com/") self.driver.find_element_by_name("q").clear() self.driver.find_element_by_name("q").send_keys("djrocket&space") self.driver.find_element_by_css_selector("input.search-submit").click() self.driver.find_element_by_xpath("//div[@id='profile-index']/div[3]/a/img").click() self.driver.find_element_by_xpath("//form[@id='profile-follow']/a/span").click() self.driver.find_element_by_css_selector("a.btn").click() self.driver.save_screenshot("/Users/ian.griffith/Desktop/automationscreenshots/main_page.png") #................. End Follow/Unfollow/Search___ begin create chart def addChart(self, djname, photo2, random1, bio): self.driver.get("http://stage-dj.beatport.com/") self.driver.find_element_by_css_selector("a.btn").click() self.driver.find_element_by_link_text("Create New Chart").click() self.driver.find_element_by_id("chart_name").clear() self.driver.find_element_by_id("chart_name").send_keys(self.djname + "'s Chart") self.driver.find_element_by_id("chart_description").clear() self.driver.find_element_by_id("chart_description").send_keys("dj" + str(self.random1) + " password beatport1 -------- " + self.bio + " ${biostage1}") self.driver.find_element_by_id("chart_image").send_keys("/Users/ian.griffith/Desktop/numbered_djs/dj" + str(self.photo2) + ".jpg") self.driver.find_element_by_css_selector("input.btn.primary").click() self.driver.find_element_by_link_text("+ Add Tracks").click() self.driver.find_element_by_id("term").clear() self.driver.find_element_by_id("term").send_keys("happy") self.driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[3]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[4]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[5]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[6]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[7]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[8]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[9]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[11]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[10]").click() self.driver.find_element_by_xpath("(//input[@value='Add Track'])[13]").click() time.sleep(6) self.driver.find_element_by_id("publish-chart-link").click() time.sleep(6) self.driver.find_element_by_css_selector("#publish-modal > div.modal-footer > form.nonAjax > input.btn.primary").click() #_______________________End create Chart________Begin create event def addEvent(self, photo5, event): self.driver.get("http://dj.beatport.com/events/" + str(self.event)) Event_Title = self.driver.find_element_by_css_selector("h1").text self.driver.get("http://stage-dj.beatport.com/") self.driver.find_element_by_css_selector("a.btn").click() self.driver.find_element_by_link_text("Create New Event").click() self.driver.find_element_by_id("event_title").clear() self.driver.find_element_by_id("event_title").send_keys(Event_Title) self.driver.find_element_by_id("event_image").send_keys("/Users/ian.griffith/Desktop/numbered_djs/dj" + str(self.photo5) + ".jpg") self.driver.find_element_by_id("event_description").click() self.driver.find_element_by_id("event_description").clear() self.driver.find_element_by_id("event_description").send_keys("dj" + str(self.random1) + " password beatport1 -------- " + str(self.bio) + " ${biostage1}") self.driver.find_element_by_css_selector("input.btn.primary").click() self.driver.find_element_by_id("venueName").click() self.driver.find_element_by_id("venueName").clear() self.driver.find_element_by_id("venueName").send_keys(self.djname + "'s Venue") self.driver.find_element_by_css_selector("input.btn.primary").click() self.driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").clear() self.driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("DJRocket&Space") self.driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) self.driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() time.sleep(4) self.driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").clear() time.sleep(4) self.driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("Nick Doyle") self.driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) self.driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() time.sleep(4) self.driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("invalyd") self.driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) self.driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() time.sleep(4) self.driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("mcguyface") self.driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) self.driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() self.driver.find_element_by_css_selector("span.drop-menu-prompt").click() self.driver.find_element_by_link_text("Log Out").click() def verifypaypal(self): driver=self.driver driver.get("http://stage-dj.beatport.com/") driver.find_element_by_css_selector("a > span").click() time.sleep(10) driver.find_element_by_xpath("//div[@id='body']/div/div/div[3]/ul/li[4]/div/div[2]/div/div[2]/div/a/span[3]/span").click() # driver.find_element_by_xpath("//div[@id='body']/div/div/div[3]/ul/li[2]/div/div[2]/div/div[2]/div/a/span[2]")click() driver.find_element_by_css_selector("span.count").click() driver.find_element_by_css_selector("a.btn-submit.evtCheckout > span").click() driver.find_element_by_id("radio-pay-pal").click() driver.find_element_by_id("billTo_street1").clear() driver.find_element_by_id("billTo_street1").send_keys("ian street") driver.find_element_by_id("billTo_city").clear() driver.find_element_by_id("billTo_city").send_keys("chico") driver.find_element_by_id("billTo_postalCode").clear() driver.find_element_by_id("billTo_postalCode").send_keys("94107") # ERROR: Caught exception [ReferenceError: selectLocator is not defined] driver.find_element_by_css_selector("button.btn-submit.").click() driver.find_element_by_link_text("Account Settings").click() # Warning: verifyTextPresent may require manual changes try: self.assertRegexpMatches(driver.find_element_by_css_selector("BODY").text, "^[\\s\\S]*City\nchico[\\s\\S]*$") except AssertionError as e: self.verificationErrors.append(str(e)) # Warning: verifyTextPresent may require manual changes try: self.assertRegexpMatches(driver.find_element_by_css_selector("BODY").text, "^[\\s\\S]*Postal Code\n94107[\\s\\S]*$") except AssertionError as e: self.verificationErrors.append(str(e)) # Warning: verifyTextPresent may require manual changes try: self.assertRegexpMatches(driver.find_element_by_css_selector("BODY").text, "^[\\s\\S]*Card Type\nPayPal[\\s\\S]*$") except AssertionError as e: self.verificationErrors.append(str(e)) # Warning: verifyTextPresent may require manual changes try: self.assertRegexpMatches(driver.find_element_by_css_selector("BODY").text, "^[\\s\\S]*Street Address\nian street[\\s\\S]*$") except AssertionError as e: self.verificationErrors.append(str(e)) driver.find_element_by_link_text("Log Out").click() # # # def testFullRegression(self): ## self.registerDJ(self.djname, self.random1) # self.verifypaypal # def testFullRegression(self): self.registerDJ(self.djname, self.random1) self.createProfile(self.djname, self.random1, self.rndgenre1, self.rndgenre2, self.rndgenre3) self.addVideo() self.addSoundCloud() self.addSearchFollow() self.addChart(self.djname, self.photo2, self.random1, self.bio) self.addEvent(self.event, self.photo5) self.registerDJ(self.djname, self.random1) self.createProfile(self.djname, self.random1, self.rndgenre1, self.rndgenre2, self.rndgenre3) self.addVideo() self.addSoundCloud() self.addSearchFollow() self.addChart(self.djname, self.photo2, self.random1, self.bio) self.addEvent(self.event, self.photo5) self.registerDJ(self.djname, self.random1) self.createProfile(self.djname, self.random1, self.rndgenre1, self.rndgenre2, self.rndgenre3) self.addVideo() self.addSoundCloud() self.addSearchFollow() self.addChart(self.djname, self.photo2, self.random1, self.bio) self.addEvent(self.event, self.photo5) self.registerDJ(self.djname, self.random1) self.createProfile(self.djname, self.random1, self.rndgenre1, self.rndgenre2, self.rndgenre3) self.addVideo() self.addSoundCloud() self.addSearchFollow() self.addChart(self.djname, self.photo2, self.random1, self.bio) self.addEvent(self.event, self.photo5) self.registerDJ(self.djname, self.random1) self.createProfile(self.djname, self.random1, self.rndgenre1, self.rndgenre2, self.rndgenre3) self.addVideo() self.addSoundCloud() self.addSearchFollow() self.addChart(self.djname, self.photo2, self.random1, self.bio) self.addEvent(self.event, self.photo5) self.registerDJ(self.djname, self.random1) self.createProfile(self.djname, self.random1, self.rndgenre1, self.rndgenre2, self.rndgenre3) self.addVideo() self.addSoundCloud() self.addSearchFollow() self.addChart(self.djname, self.photo2, self.random1, self.bio) self.addEvent(self.event, self.photo5) def is_element_present(self, how, what): try: self.driver.find_element(by=how, value=what) except NoSuchElementException, e: return False return True def tearDown(self): self.driver.quit() self.screenCapture.stop(); self.assertEqual([], self.verificationErrors)
from castro import Castro import subprocess, os, sys from subprocess import Popen, PIPE, STDOUT if sys.platform == "darwin": print 'launching slave process...' env = os.environ.copy() print env print sys.platform for x in range(1, 9): tc_name = "TC_%03d" % x # TC_001 TC_002 ... TC_008 c = Castro(display=1, passwd="/Users/labuser/.vinevncauth", filename=tc_name + "_screencast.swf") c.start() ruby = subprocess.call(['rake', tc_name], env=env) print ruby c.stop() else: if __name__ == '__main__': print 'launching slave process...' env = os.environ.copy() print env print sys.platform for x in range(1, 9): tc_name = "TC_%03d" % x # TC_001 TC_002 ... TC_008 c = Castro(display=1, filename=tc_name + "_screencast.swf") c.start() ruby = subprocess.call(['ruby', '-S', 'rake', tc_name], env=env) print ruby
class one_profile (unittest.TestCase): def setUp(self): self.screenCapture = Castro(filename="createprofile.swf") self.screenCapture.start() self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "http://stage-dj.beatport.com/" self.verificationErrors = [] def test_python_webdriver_unittest_full_regression(self): bio = " " driver = self.driver event = random.randrange(1,47000,1); profile = random.randrange(1,150000,1); random1 = random.randrange(2000,10000,1); photo = random.randrange(1,1043,1); photo2 = random.randrange(1,1043,1); photo5 = random.randrange(1,1043,1); rndgenre1 = random.randrange(1,23,1); rndgenre2 = random.randrange(1,23,1); rndgenre3 = random.randrange(1,23,1); rndgenre4 = random.randrange(1,23,1); rndgenre5 = random.randrange(1,23,1); rndgenre6 = random.randrange(1,23,1); dj1 = random.randrange(1,15,1); print dj1 print random1 print event print photo print photo2 print photo5 print profile driver.get("http://dj.beatport.com/profile/" + str(profile)) profile_url = driver.current_url print(profile_url) djname = driver.find_element_by_css_selector("h1").text print(djname) #____________________________________________End Gathering Data__Begin registering driver.get("http://stage-dj.beatport.com/") time.sleep(3) driver.get("https://stage-accounts.beatport.com/register") driver.find_element_by_id("first-name").clear() driver.find_element_by_id("first-name").send_keys(djname) driver.find_element_by_id("last-name").clear() driver.find_element_by_id("last-name").send_keys(djname) driver.find_element_by_id("emailAddress").clear() driver.find_element_by_id("emailAddress").send_keys("ian.griffith+" + str(random1) +"@beatport.com") driver.find_element_by_id("confirmEmailAddress").clear() driver.find_element_by_id("confirmEmailAddress").send_keys("ian.griffith+" + str(random1) +"@beatport.com") driver.find_element_by_id("username").clear() driver.find_element_by_id("username").send_keys("dj" + str(random1)) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys("beatport1") driver.find_element_by_id("confirmPassword").clear() driver.find_element_by_id("confirmPassword").send_keys("beatport1") #changed the submit button - was searching it by css-selector, i changed it to xpath driver.find_element_by_xpath("//button[@type=\"submit\"]").click() #switching back to home page after registration in next 2 lines #_____________________________________________End registering account__begin create dj profile time.sleep(3) driver.get("http://stage-dj.beatport.com/") driver.switch_to_default_content() driver.find_element_by_id("logo").click() time.sleep(3) driver.find_element_by_xpath("//*[@id=\"header\"]/div/div[2]/ul/li[3]/a").click() driver.find_element_by_id("profile_name").clear() driver.find_element_by_id("profile_name").send_keys(djname) driver.find_element_by_id("profile_slug").clear() driver.find_element_by_id("profile_slug").send_keys("djname" + str(random1)) driver.find_element_by_id("profile_bio").clear() driver.find_element_by_id("profile_bio").send_keys("dj" + str(random1) + " password beatport1 -------- " + bio) driver.find_element_by_id("profile_image").send_keys("/Users/ian.griffith/Desktop/numbered_djs/dj" + str(photo) + ".jpg") driver.find_element_by_xpath("//input[@value='Create Profile']").click() time.sleep(4) # ___create dj profile___Begin genres driver.find_element_by_xpath("//div[@id='genre-list']/ul/li[" + str(rndgenre1) + "]").click() driver.find_element_by_xpath("//div[@id='genre-list']/ul/li[" + str(rndgenre2) + "]").click() driver.find_element_by_xpath("//div[@id='genre-list']/ul/li[" + str(rndgenre3) + "]").click() time.sleep(4) # __create dj profile____begin management driver.find_element_by_link_text("Management").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("griffith1") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("merrix") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("sillyhat") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("seanbo333") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("blissriot") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("paula") driver.find_element_by_xpath("//input[@value='Add Manager']").click() driver.find_element_by_name("username").clear() driver.find_element_by_name("username").send_keys("prldd") driver.find_element_by_xpath("//input[@value='Add Manager']").click() #__________create dj profile______begin video add driver.find_element_by_link_text("Videos").click() driver.find_element_by_id("video_url").clear() driver.find_element_by_id("video_url").send_keys("http://www.youtube.com/watch?v=IzgFXpZsLYA&feature=plcp") driver.find_element_by_xpath("//input[@value='Add Video']").click() driver.find_element_by_id("video_url").click() driver.find_element_by_id("video_url").clear() driver.find_element_by_id("video_url").send_keys("http://www.youtube.com/watch?v=cHzhlJ48UjM&feature=plcp") driver.find_element_by_xpath("//input[@value='Add Video']").click() time.sleep(4) #___________create dj profile________begin Soundcloud add driver.find_element_by_link_text("SoundCloud").click() driver.find_element_by_link_text("Individual Tracks").click() driver.find_element_by_id("soundcloud_track_url").clear() driver.find_element_by_id("soundcloud_track_url").send_keys("http://soundcloud.com/maisondragen/armin-van-buuren-we-are-here-to-make-some-noise-maison-dragen-remix-edit") driver.find_element_by_xpath("//input[@value='Add Track']").click() #............... End Create DJ Profile___ begin search/follow/unfollow driver.get("http://stage-dj.beatport.com/") driver.find_element_by_name("q").clear() driver.find_element_by_name("q").send_keys("djrocket&space") driver.find_element_by_css_selector("input.search-submit").click() driver.find_element_by_xpath("//div[@id='profile-index']/div[3]/a/img").click() driver.find_element_by_xpath("//form[@id='profile-follow']/a/span").click() driver.find_element_by_css_selector("a.btn").click() driver.save_screenshot("/Users/ian.griffith/Desktop/automationscreenshots/main_page.png") #................. End Follow/Unfollow/Search___ begin create chart driver.find_element_by_link_text("Create New Chart").click() driver.find_element_by_id("chart_name").clear() driver.find_element_by_id("chart_name").send_keys(djname + "'s Chart") driver.find_element_by_id("chart_description").clear() driver.find_element_by_id("chart_description").send_keys("dj" + str(random1) + " password beatport1 -------- " + bio + " ${biostage1}") driver.find_element_by_id("chart_image").send_keys("/Users/ian.griffith/Desktop/numbered_djs/dj" + str(photo2) + ".jpg") driver.find_element_by_css_selector("input.btn.primary").click() driver.find_element_by_link_text("+ Add Tracks").click() driver.find_element_by_id("term").clear() driver.find_element_by_id("term").send_keys("happy") driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[3]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[4]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[5]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[6]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[7]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[8]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[9]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[11]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[10]").click() driver.find_element_by_xpath("(//input[@value='Add Track'])[13]").click() time.sleep(6) driver.find_element_by_id("publish-chart-link").click() time.sleep(6) #_______________________End create Chart________Begin create event driver.find_element_by_css_selector("#publish-modal > div.modal-footer > form.nonAjax > input.btn.primary").click() driver.get("http://dj.beatport.com/events/" + str(event)) Event_Title = driver.find_element_by_css_selector("h1").text driver.get("http://stage-dj.beatport.com/") driver.find_element_by_css_selector("a.btn").click() driver.find_element_by_link_text("Create New Event").click() driver.find_element_by_id("event_title").clear() driver.find_element_by_id("event_title").send_keys(Event_Title) driver.find_element_by_id("event_image").send_keys("/Users/ian.griffith/Desktop/numbered_djs/dj" + str(photo5) + ".jpg") driver.find_element_by_id("event_description").click() driver.find_element_by_id("event_description").clear() driver.find_element_by_id("event_description").send_keys("dj" + str(random1) + " password beatport1 -------- " + str(bio) + " ${biostage1}") driver.find_element_by_css_selector("input.btn.primary").click() driver.find_element_by_id("venueName").click() driver.find_element_by_id("venueName").clear() driver.find_element_by_id("venueName").send_keys(djname + "'s Venue") driver.find_element_by_css_selector("input.btn.primary").click() driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").clear() driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("DJRocket&Space") driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() time.sleep(4) driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").clear() time.sleep(4) driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("Nick Doyle") driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() time.sleep(4) driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("invalyd") driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() time.sleep(4) driver.find_element_by_css_selector("#dj-search > input[name=\"q\"]").send_keys("mcguyface") driver.find_element_by_xpath("(//input[@value='Search'])[2]").click() time.sleep(4) driver.find_element_by_xpath("//div[@id='profile-index']/div[2]/a/img").click() driver.find_element_by_css_selector("span.drop-menu-prompt").click() # End create Event driver.find_element_by_link_text("Log Out").click() print("") def is_element_present(self, how, what): try: self.driver.find_element(by=how, value=what) except NoSuchElementException, e: return False return True def tearDown(self): self.driver.quit() self.screenCapture.stop(); self.assertEqual([], self.verificationErrors)
from castro import Castro from time import sleep import os if __name__ == "__main__": output_file_path = os.path.join(os.getcwd(), "test_video.swf") vnc_file_path = os.path.join(os.getcwd(), "vnc_passwd") #Create a Castro video object video = Castro(filename = output_file_path, passwd = vnc_file_path) #start screen recording print "\nStarting 10-second screen capture...\n" video.start() sleep(10) #stop recording and save video file video.stop()
from easyprocess import EasyProcess import pyscreenshot as ps from pyvirtualdisplay.smartdisplay import SmartDisplay, Display from castro import Castro import time count = 0 castro = Castro() castro.start() EasyProcess('google-chrome http://www.youtube.com') time.sleep(10) castro.stop()
from castro import Castro import subprocess, os, sys from subprocess import Popen, PIPE, STDOUT if sys.platform == "darwin": print "launching slave process..." env = os.environ.copy() print env print sys.platform for x in range(1, 9): tc_name = "TC_%03d" % x # TC_001 TC_002 ... TC_008 c = Castro(display=1, passwd="/Users/labuser/.vinevncauth", filename=tc_name + "_screencast.swf") c.start() ruby = subprocess.call(["rake", tc_name], env=env) print ruby c.stop() else: if __name__ == "__main__": print "launching slave process..." env = os.environ.copy() print env print sys.platform for x in range(1, 9): tc_name = "TC_%03d" % x # TC_001 TC_002 ... TC_008 c = Castro(display=1, filename=tc_name + "_screencast.swf") c.start() ruby = subprocess.call(["ruby", "-S", "rake", tc_name], env=env) print ruby c.stop()