Python selenium webdriver Chrome - Chrome is being controlled by an automated software -


i using selenium webdriver , creating chrome driver instance. when try scroll down , scroll up,i getting following error message. further can see error message 'chrome being controlled automated software'. annoying see error though not able change settings in chrome browser allowing automation.

from selenium import webdriver selenium.webdriver.common.keys import keys selenium.webdriver.support import expected_conditions ec selenium.webdriver.common.by import selenium.webdriver.support.ui import webdriverwait wait selenium.common.exceptions import timeoutexception  log_util.logger import log log  import time  log = log()   class wiki(object):     def __init__(self):         self.link = 'http://wikipedia.org'         self.path = '/users/swadhikar_c/downloads/chromedriver'         self.driver = webdriver.chrome(executable_path=self.path)      def open_wiki(self):         driver = self.driver         driver.get(self.link)         return self.wait_for_page_load()      def wait_for_page_load(self, timeout=200):         is_element_located = ec.presence_of_element_located((by.class_name, 'central-featured-logo'))          try:             wait(self.driver, timeout=int(timeout)).until(is_element_located)             print("page loaded successfully")             time.sleep(5)         except timeoutexception:             print("operation timed out")             raise          return 1      def scroll_down_up(self):         driver = self.driver          element = driver.find_element(by.tag_name, 'html')         element.send_keys(keys.end)          print("scrolled down end!")         time.sleep(5)          element.send_keys(keys.home)          print("scrolled top!")         time.sleep(5)      def close_driver(self):         self.driver.quit()   if __name__ == '__main__':     wiki = wiki()      try:         if not wiki.open_wiki():             print("operation failed")          wiki.scroll_down_up()      finally:         wiki.close_driver() 

error message:

/system/library/frameworks/python.framework/versions/2.7/bin/python2.7 /users/swadhikar_c/pycharm_projects/pyselenium/pyselenium/test/selenium_test.py page loaded traceback (most recent call last): file "/users/swadhikar_c/pycharm_projects/pyselenium/pyselenium/test/selenium_test.py", line 64, in wiki.scroll_down_up() file "/users/swadhikar_c/pycharm_projects/pyselenium/pyselenium/test/selenium_test.py", line 43, in scroll_down_up element.send_keys(keys.end) file "/library/python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 349, in send_keys 'value': keys_to_typing(value)}) file "/library/python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 493, in _execute return self._parent.execute(command, params) file "/library/python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 249, in execute self.error_handler.check_response(response) file "/library/python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.webdriverexception: message: unknown error: cannot focus element (session info: chrome=57.0.2987.133) (driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=mac os x 10.12.4 x86_64)

process finished exit code 1 

chrome message:

i have did digging , found resolved. modified init function below.

from selenium.webdriver.chrome.options import options  def __init__(self):     self._link = 'https://in.norton.com/'     _path = '/users/swadhikar_c/downloads/chromedriver'     _chrome_options = options()     _chrome_options.add_argument('disable-infobars')     self.driver = webdriver.chrome(executable_path=_path, chrome_options=_chrome_options) 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -