1

I'm implementing a selenium - python code to scrape through a webpage. I was able to run the program using remote webdriver without any proxy wall. However I need to run this behind a proxy wall. I couldn't figure out whether to user Proxy class or to implement proxy using Desired Capabilities? Attaching the current code without any proxy settings PS. using a DOM object model

from driver import Webdriver
from selenium.webdriver.common.proxy import Proxy
import unittest,time
desired_capabilities = { 'browserName' : 'chrome' }
command_executor = "http://127.0.0.1:4444/wd/hub"
proxy_address = 'http://proxy-chain.companyname.com:911'

from base import Login_page


class testing_first_code(unittest.TestCase):
   def setUp (self):
     self.driver = Webdriver(desired_capabilities=desired_capabilities, command_executor=command_executor )
Jishnu Ramesh
  • 617
  • 10
  • 17
  • Did you try `self.driver = Webdriver(desired_capabilities=desired_capabilities, command_executor=command_executor, proxy=proxy_address)` ? – Arun Mar 03 '17 at 06:47
  • @Arun I tried this but im getting the following error : str' object has no attribute 'add_to_capabilities' – Jishnu Ramesh Mar 03 '17 at 07:26
  • Did you try http://stackoverflow.com/questions/11450158/how-do-i-set-proxy-for-chrome-in-python-webdriver/24237188#24183276 ? – Arun Mar 03 '17 at 09:06
  • I tried this way. `desired_capabilities = { 'browserName' : 'chrome' } proxy_address = Proxy( { 'proxyType' : ProxyType.MANUAL, 'httpProxy' : 'http://proxy-chain.companyname.com:911', 'ftpProxy' : 'http://proxy-chain.companynamel.com:911', 'noProxy' : None, 'autodetect': False } ) class testing_first_code(unittest.TestCase): def setUp (self): self.driver = Webdriver(desired_capabilities=desired_capabilities, command_executor=command_executor, proxy=proxy_address )` – Jishnu Ramesh Mar 03 '17 at 11:45
  • Now getting error A communication error occurred: "Connection refused" – Jishnu Ramesh Mar 03 '17 at 11:55

0 Answers0