0

ユーザーの操作に基づいて複数のイベントをトリガーするウェブサイトがあり、自動化スクリプトを使用してそれらのシナリオをシミュレートする必要があり、Googleアナリティクスのイベントがシーンの背後にあるかどうかを理解する必要があります。Googleアナリティクスの自動化テスト

私たちが自動化するのに役立つツールが市場に出ているかどうか不思議です。ありがとう!

答えて

0

インストールChrome Extension Source Vieweranalytics debugger extension in the storeに移動し、拡張ソースビューアを使用して拡張機能のzipファイルをダウンロードします。オープンbackground.jsとChromeブラウザで

debug = true 

に編集debug = false(現在は4行目)は、拡張ウィンドウを行くのDevモード(そのウィンドウのチェックボックス)をオンにします。 Pack Extensionボタンを使用して、編集したばかりのフォルダを選択して、ga_tracker.crxというファイルを作成します。

あなたのプロジェクトにそのcrxファイルをドロップします。たとえば、私はそれを私のvirtualenvにコピーしました。

test.py 
env/ 
    bin/ 
     ga_tracker.crx 

これはpython seleniumテストのtest.pyです。 add_extensionのパスを編集します。

import re 
from selenium import webdriver 
from selenium.webdriver.chrome.options import Options 

class FindTest(): 

    def test(self): 

     self.chrome_options = webdriver.ChromeOptions() 
     self.chrome_options.add_extension('env/bin/ga_tracker.crx') 
     self.driver = webdriver.Chrome(chrome_options=self.chrome_options) 
     self.driver.get('https://www.localsbarguide.com') 
     for entry in self.driver.get_log('browser'): 
      print(entry) 
      for entry in context.driver.get_log('browser'): 
       if 'https://www.google-analytics.com/analytics_debug.js' in entry['message']: 
        my_regex = re.escape('title') + r".*." + re.escape('The Premiere Drink Special & Happy Hour resource | Locals Bar Guide San Francisco') 
        if re.search(my_regex, entry, re.IGNORECASE): 
         print('Found GA event with expected title.') 

     self.driver.quit() 

runtest = FindTest() 
runtest.test() 
関連する問題