美文网首页
获取webrtc应用运行时webrtc-internals的信息

获取webrtc应用运行时webrtc-internals的信息

作者: 㗊𨰻木㵘燚㙓㗊 | 来源:发表于2018-09-20 10:31 被阅读0次

获取webrtc应用运行时webrtc-internals的信息:

# coding = utf-8

from selenium import webdriver

import selenium.webdriver.support.ui as ui

from selenium.webdriver.common.keys import Keys

import os

import sys

import re

import time

def utf8code(ss): 

    u8 = re.sub(r'[\000-\377]*', lambda m:''.join([chr(ord(i)) for i in m.group(0)]).decode('utf8'), ss)

    return u8

def monitor(url1,url2):

    chromedriver = "C:/Users/xxx/AppData/Local/Google/Chrome/Application/chromedriver.exe"

    os.environ["webdriver.chrome.driver"] = chromedriver

    driver = webdriver.Chrome(chromedriver)

    driver.maximize_window()

    #driver.implicitly_wait(15)

    # First Tab

    driver.get(url1)

    window_handle = driver.current_window_handle

    print window_handle

    print driver.title

    time.sleep(3)

    # Second Tab

    driver.execute_script('''window.open("http://nmeeting.*****.com/", "_blank");''')

    lastParameter = ['']*10

    nowParameter = ['']*10

    isFirst=True

    for i in range(1000000):

        time.sleep(5)

        for peer in range(1,10):

            xpath="//*[@id=\"content-root\"]/div[1]/span["+str(peer)+"]"

            try:

                driver.find_element_by_xpath(xpath).is_displayed()

            except:

                x=0#

            else:

                peerUrl = driver.find_element_by_xpath(xpath).text

                #print peerUrl

                if peerUrl == 'GetUserMedia Requests':

                    continue

                driver.find_element_by_xpath(xpath).click()

                peerId = str(str(peerUrl).split("[")[1]).split("]")[0]

                parameter = ['']*9

                timestamp = str(peerId) + '-table-bweforvideo-timestamp'

                googAvailableSendBandwidth = str(peerId) + '-table-bweforvideo-googAvailableSendBandwidth'

                googAvailableReceiveBandwidth = str(peerId) + '-table-bweforvideo-googAvailableReceiveBandwidth'

                googTargetEncBitrate = str(peerId) + '-table-bweforvideo-googTargetEncBitrate'

                googActualEncBitrate = str(peerId) + '-table-bweforvideo-googActualEncBitrate'

                googRetransmitBitrate = str(peerId) + '-table-bweforvideo-googRetransmitBitrate'

                googTransmitBitrate = str(peerId) + '-table-bweforvideo-googTransmitBitrate'

                googBucketDelay = str(peerId) + '-table-bweforvideo-googBucketDelay'

                googReceivedPacketGroupPropagationDeltaSumDebug = str(peerId) + '-table-bweforvideo-googReceivedPacketGroupPropagationDeltaSumDebug'           

                parameter[0] = timestamp

                parameter[1] = googAvailableSendBandwidth

                parameter[2] = googAvailableReceiveBandwidth

                parameter[3] = googTargetEncBitrate

                parameter[4] = googActualEncBitrate

                parameter[5] = googRetransmitBitrate

                parameter[6] = googTransmitBitrate

                parameter[7] = googBucketDelay

                parameter[8] = googReceivedPacketGroupPropagationDeltaSumDebug

                print '***' + str(peerId) + '***'

                xpath_bweforvideo = "//*[@id=\"" + parameter[0] + "\"]"

                print driver.find_element_by_xpath(xpath_bweforvideo).text #

                #

                for j in range(1,9):

                    xpath_bweforvideo = "//*[@id=\"" + parameter[j] + "\"]"

                    try:

                        driver.find_element_by_xpath(xpath_bweforvideo).is_displayed()

                    except:

                        x=0#

                    else:             

                        if nowParameter[peer] == '':

                            nowParameter[peer] = driver.find_element_by_xpath(xpath_bweforvideo).text

                        else:

                            nowParameter[peer] = nowParameter[peer] + '\n' + driver.find_element_by_xpath(xpath_bweforvideo).text

                print nowParameter[peer]

                if isFirst == False:

                    if lastParameter[peer] == nowParameter[peer] and lastParameter[peer] != '' and nowParameter[peer] != '':

                        print str(peerId) + utf8code("error")

                isFirst = False

                lastParameter[peer] = nowParameter[peer]

                nowParameter[peer] = ''

                print

        print "--------------------------------------------------------------------------"

if __name__ == '__main__':

    reload(sys)

    sys.setdefaultencoding("utf8")   

    url1 = "chrome://webrtc-internals/"

    url2 = "http://nmeeting.*****.com/"

    monitor(url1,url2)

    print 'ok'

相关文章

网友评论

      本文标题:获取webrtc应用运行时webrtc-internals的信息

      本文链接:https://www.haomeiwen.com/subject/khugnftx.html