def test_control(self): results = [] # Get provider data t = TXTProvider('product_urls.txt') # Load the control preview url w = WalmartPage(self.driver) w.open_control_preview_url() for url in t.data: # Execute the Google redirect g = GooglePage(self.driver) g.redirect(url) # Get the list of recommendations recs = w.get_control_recommendations() # Append recommendation data to results d = collections.OrderedDict() d['product_id'] = url.split('/')[-1] d['url'] = url d['num_recommendations'] = len(recs) d['recommendations'] = recs results.append(d) # Save screenshot to disk #w.save_screenshot("control_{0}".format(d['product_id'])) with open("results/control.json", "w") as f: f.write(json.dumps(results, sort_keys=False))
def test_control(self): # Load the control page c = ControlPage(self.driver) c.open_default_url() # Execute the google search and click our result g = GooglePage(self.driver) g.open_default_url() g.search_for("canon t2i walmart") g.click_result_title("Canon DSLR Camera, EOS Rebel T2i, 18-55mm Lens - Walmart.com")
def test_variant1(self): # Make connection with SiteSpect # s = SiteSpectPage(self.driver) # s.open_default_url() v = VariantPage(self.driver) # Load the variant preview # v.open_preview_url() # v.accept_alert() # Set the variant cookie v.open_default_url() v.set_cookie() import sys, time referer = {"referer": "http://www.google.com?q=anything"} self.client.headers(referer) self.driver.get("http://www.walmart.com/ip/20604608") time.sleep(60) sys.exit() # Execute the google search and click our result self.client.new_har("google") g = GooglePage(self.driver) g.open_default_url() g.search_for("canon t2i walmart") g.click_result_title("Canon DSLR Camera, EOS Rebel T2i, 18-55mm Lens - Walmart.com") # v.accept_alert() # v.accept_alert() # v.accept_alert() h = self.client.har() # import json # print json.dumps(h) proxy.close() driver.quit() import sys sys.exit()
def test_google_search(self, browser, link): page = GooglePage(browser, link) page.open() page.enter_request('купить кофемашину bork c804') page.check_results()