如何使用selenium刷新Python中现有的网页?

时间:2016-12-01 10:16:46

标签: javascript python html python-2.7

我正在尝试显示在特定时间间隔后使用python附加到网页中的不同记录。但我的代码不断打开新的浏览器窗口,而不是在已打开的网页中显示。我该如何解决这个问题?

    records = graphlab.SFrame("R.csv")
    records_banks = records['Name']
    records_banks = set(records_banks)
    for i in records_banks:
        records_b = records[records['Name']==i]
        a = records_b['Merchant']
        b = records_b['Success']
        c = records_b['Failure']
        a= map(str,a)
        b = map(int,b)
        c = map(int,c)
        py.sign_in('su001', '66dtyRd7Ysh9m8CqL78o')
        trace1 = go.Bar(
        x=a,
        y=b,
        name='Success'
        )
        trace2 = go.Bar(
        x=a,
        y=c,
        name='Failure'
        )

        data = [trace1, trace2]
        layout = go.Layout(
        barmode='stack'
        )

        fig = go.Figure(data=data, layout=layout)
        py.iplot(fig, filename='stacked-bar')
        driver = webdriver.Chrome("C:/Users/S/Desktop/Python/chromedriver.exe")
        driver.get('file://C:/Users/S/Desktop/Python/testdata.html')
        time.sleep(3)
        driver.refresh()

1 个答案:

答案 0 :(得分:0)

你可以尝试

driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 'r')

或driver.refresh()

来源 - How to refresh an already opened web page