MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / generate_referral

Method generate_referral

seleniumbase/fixtures/base_case.py:10268–10305  ·  view source on GitHub ↗

This method opens the start_page, creates a referral link there, and clicks on that link, which goes to the destination_page. If a selector is given, clicks that on the destination_page, which can prevent an artificial rise in website bounce-rate. (This generates real

(self, start_page, destination_page, selector=None)

Source from the content-addressed store, hash-verified

10266 ############
10267
10268 def generate_referral(self, start_page, destination_page, selector=None):
10269 """This method opens the start_page, creates a referral link there,
10270 and clicks on that link, which goes to the destination_page.
10271 If a selector is given, clicks that on the destination_page,
10272 which can prevent an artificial rise in website bounce-rate.
10273 (This generates real traffic for testing analytics software.)"""
10274 self.__check_scope()
10275 if not page_utils.is_valid_url(destination_page):
10276 raise Exception(
10277 "Exception: destination_page {%s} is not a valid URL!"
10278 % destination_page
10279 )
10280 if start_page:
10281 if not page_utils.is_valid_url(start_page):
10282 raise Exception(
10283 "Exception: start_page {%s} is not a valid URL! "
10284 "(Use an empty string or None to start from current page.)"
10285 % start_page
10286 )
10287 self.open(start_page)
10288 time.sleep(0.08)
10289 self.wait_for_ready_state_complete()
10290 referral_link = (
10291 """<body>"""
10292 """<a class='analytics referral test' href='%s' """
10293 """style='font-family: Arial,sans-serif; """
10294 """font-size: 30px; color: #18a2cd'>"""
10295 """Magic Link Button</a></body>""" % destination_page
10296 )
10297 self.execute_script(
10298 '''document.body.outerHTML = \"%s\"''' % referral_link
10299 )
10300 # Now click the generated button
10301 self.click("a.analytics.referral.test", timeout=2)
10302 time.sleep(0.15)
10303 if selector:
10304 self.click(selector)
10305 time.sleep(0.15)
10306
10307 def generate_traffic(
10308 self, start_page, destination_page, loops=1, selector=None

Callers 2

generate_trafficMethod · 0.95

Calls 7

__check_scopeMethod · 0.95
openMethod · 0.95
execute_scriptMethod · 0.95
clickMethod · 0.95
is_valid_urlMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected