如何使用Selenium和Robot Framework在Chrome中添加和获取cookie值

时间:2017-06-25 22:16:04

标签: google-chrome selenium cookies robotframework selenium2library

我最近一直在学习Selenium2Library的Robot Framework,我有一个小问题。

我尝试将Cookie添加到在Chrome中打开的网站,然后检索其值以确保它等于预期值。

resources.txt

    *** Settings ***
Library           Selenium2Library
Library           OperatingSystem

*** Variables ***
${browser}        chrome

cookieKeywords

*** Settings ***
Resource          resources.txt

*** Variables ***
${CookieValue}    ${EMPTY}
${ExpectedCookieValue}    somevalue

*** Test Cases ***
CookieTest
    Open Browser    http://www.google.pl    ${browser}
    Add Cookie    CookieTest    somevalue
    ${CookieValue}    Get Cookie Value    CookieTest
    Should Be Equal    ${CookieValue}    ${ExpectedCookieValue}    "Cookie is equal"
    Close Browser

Screen with project tree and error

看起来我无法向使用chrome打开的网站添加临时cookie ...

也许有人发生了同样的问题?

1 个答案:

答案 0 :(得分:1)

重新安装Chrome浏览器有助于:)