webfp / tor-browser-selenium

Tor Browser automation with Selenium.
MIT License
556 stars 99 forks source link

AttributeError: 'TorBrowserDriver' object has no attribute 'add_cookies' #121

Closed Slava096 closed 5 years ago

Slava096 commented 5 years ago

my code

from argparse import ArgumentParser
from tbselenium.tbdriver import TorBrowserDriver

def print_cookies(tbb_dir, url):
    with TorBrowserDriver(tbb_dir) as driver:
        driver.load_url(url)
        print ("Finished loading", url)
        print ("Cookies:", driver.execute_script("return document.cookie;"))
        driver.add_cookies({})    

def mainn():
    desc = "Print cookies on a given URL"
    nyt_hs_url = "https://www.nytimes3xbfgragh.onion/"  # NYT Hidden Service
    parser = ArgumentParser(description=desc)
    parser.add_argument('tbb_path')
    parser.add_argument('url', default=nyt_hs_url)
    args = parser.parse_args()
    print_cookies(args.tbb_path, args.url)

mainn()

all libraries updated to the latest versions.

gunesacar commented 5 years ago

There is no webdriver method called add_cookies, but there is add_cookie. The code works if you replace driver.add_cookies({}) with the following: driver.add_cookie({'name' : 'foo', 'value' : 'bar'})