@@ -1824,6 +1824,8 @@ def pick_select_option_by_value(self, dropdown_selector, option,
1824
1824
dropdown_by = dropdown_by , option_by = "value" ,
1825
1825
timeout = timeout )
1826
1826
1827
+ ############
1828
+
1827
1829
def generate_referral (self , start_page , destination_page ):
1828
1830
""" This method opens the start_page, creates a referral link there,
1829
1831
and clicks on that link, which goes to the destination_page.
@@ -1843,7 +1845,7 @@ def generate_referral(self, start_page, destination_page):
1843
1845
referral_link = ('''<a class='analytics referral test' href='%s' '''
1844
1846
'''style='font-family: Arial,sans-serif; '''
1845
1847
'''font-size: 30px; color: #18a2cd'>'''
1846
- '''* Magic Link Button! * </a>''' % destination_page )
1848
+ '''Magic Link Button</a>''' % destination_page )
1847
1849
self .execute_script (
1848
1850
'''document.body.innerHTML = \" %s\" ''' % referral_link )
1849
1851
time .sleep (0.1 )
@@ -1861,6 +1863,32 @@ def generate_traffic(self, start_page, destination_page, loops=1):
1861
1863
self .generate_referral (start_page , destination_page )
1862
1864
time .sleep (0.05 )
1863
1865
1866
+ def generate_referral_chain (self , pages ):
1867
+ """ Use this method to chain the action of creating button links on
1868
+ one website page that will take you to the next page.
1869
+ (When you want to create a referral to a website for traffic
1870
+ generation without increasing the bounce rate, you'll want to visit
1871
+ at least one additional page on that site with a button click.) """
1872
+ if not type (pages ) is tuple and not type (pages ) is list :
1873
+ raise Exception (
1874
+ "Exception: Expecting a list of website pages for chaining!" )
1875
+ if len (pages ) < 2 :
1876
+ raise Exception (
1877
+ "Exception: At least two website pages required for chaining!" )
1878
+ for page in pages :
1879
+ # Find out if any of the web pages are invalid before continuing
1880
+ if not page_utils .is_valid_url (page ):
1881
+ raise Exception (
1882
+ "Exception: Website page {%s} is not a valid URL!" % page )
1883
+ for page in pages :
1884
+ self .generate_referral (None , page )
1885
+
1886
+ def generate_traffic_chain (self , pages , loops = 1 ):
1887
+ """ Similar to generate_referral_chain(), but for multiple loops. """
1888
+ for loop in range (loops ):
1889
+ self .generate_referral_chain (pages )
1890
+ time .sleep (0.05 )
1891
+
1864
1892
############
1865
1893
1866
1894
def wait_for_element_present (self , selector , by = By .CSS_SELECTOR ,
0 commit comments