ide:pycharm
language:python 2.7
selenium:3.141.0
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.chrome.options import Options
if __name__ == '__main__':
options = Options()
options.add_argument("--incognito")
path = "/Users/apple/Seleniumdriver/chromedriver"
driver = WebDriver(executable_path=path, options=options,
service_log_path="log.txt")
driver.get("https://www.baidu.com")
driver.find_element_by_name("tj_trhao123").click()
driver.close()
driver.quit()
log.txt
[1554742430.803][INFO]: Starting ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72)
[1554742430.803][INFO]: Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1554742431.801][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] COMMAND InitSession {
"capabilities": {
"alwaysMatch": {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [ "--incognito" ],
"extensions": [ ]
},
"platformName": "any"
},
"firstMatch": [ {
} ]
},
"desiredCapabilities": {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [ "--incognito" ],
"extensions": [ ]
},
"platform": "ANY",
"version": ""
}
}
[1554742431.803][INFO]: Populating Preferences file: {
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"check_default_browser": false
},
"distribution": {
"import_bookmarks": false,
"import_history": false,
"import_search_engine": false,
"make_chrome_default_for_user": false,
"skip_first_run_ui": true
},
"dns_prefetching": {
"enabled": false
},
"profile": {
"content_settings": {
"pattern_pairs": {
"https://*,*": {
"media-stream": {
"audio": "Default",
"video": "Default"
}
}
}
},
"default_content_setting_values": {
"geolocation": 1
},
"default_content_settings": {
"geolocation": 1,
"mouselock": 1,
"notifications": 1,
"popups": 1,
"ppapi-broker": 1
},
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"translate": {
"enabled": false
}
}
[1554742431.804][INFO]: Populating Local State file: {
"background_mode": {
"enabled": false
},
"ssl": {
"rev_checking": {
"enabled": false
}
}
}
[1554742431.805][INFO]: Launching chrome: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --incognito --load-extension=/var/folders/nt/33z_3wbj0x76ckgm5dvh7x2m0000gn/T/.com.google.Chrome.AC3Gpi/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/var/folders/nt/33z_3wbj0x76ckgm5dvh7x2m0000gn/T/.com.google.Chrome.FHP0mS data:,
[1554742432.810][INFO]: resolved localhost to ["::1","127.0.0.1"]
[1554742432.930][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] RESPONSE InitSession {
"acceptInsecureCerts": false,
"acceptSslCerts": false,
"applicationCacheEnabled": false,
"browserConnectionEnabled": false,
"browserName": "chrome",
"chrome": {
"chromedriverVersion": "73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72)",
"userDataDir": "/var/folders/nt/33z_3wbj0x76ckgm5dvh7x2m0000gn/T/.com.google.Chrome.FHP0mS"
},
"cssSelectorsEnabled": true,
"databaseEnabled": false,
"goog:chromeOptions": {
"debuggerAddress": "localhost:59724"
},
"handlesAlerts": true,
"hasTouchScreen": false,
"javascriptEnabled": true,
"locationContextEnabled": true,
"mobileEmulationEnabled": false,
"nativeEvents": true,
"networkConnectionEnabled": false,
"pageLoadStrategy": "normal",
"platform": "Mac OS X",
"proxy": {
},
"~~~": "..."
}
[1554742432.932][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] COMMAND Navigate {
"sessionId": "73dc6c6f7738cf251f15cdb165ab0efe",
"url": "https://www.baidu.com"
}
[1554742432.932][INFO]: Waiting for pending navigations...
[1554742432.933][INFO]: Done waiting for pending navigations. Status: ok
[1554742433.179][INFO]: Waiting for pending navigations...
[1554742433.498][INFO]: Done waiting for pending navigations. Status: ok
[1554742433.498][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] RESPONSE Navigate
[1554742433.500][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] COMMAND FindElement {
"sessionId": "73dc6c6f7738cf251f15cdb165ab0efe",
"using": "name",
"value": "tj_trhao123"
}
[1554742433.500][INFO]: Waiting for pending navigations...
[1554742433.500][INFO]: Done waiting for pending navigations. Status: ok
[1554742433.513][INFO]: Waiting for pending navigations...
[1554742433.514][INFO]: Done waiting for pending navigations. Status: ok
[1554742433.514][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] RESPONSE FindElement {
"ELEMENT": "0.061980472350435356-1"
}
[1554742433.516][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] COMMAND ClickElement {
"id": "0.061980472350435356-1",
"sessionId": "73dc6c6f7738cf251f15cdb165ab0efe"
}
[1554742433.516][INFO]: Waiting for pending navigations...
[1554742433.517][INFO]: Done waiting for pending navigations. Status: ok
[1554742433.574][INFO]: Waiting for pending navigations...
[1554742511.966][INFO]: Done waiting for pending navigations. Status: ok
[1554742511.966][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] RESPONSE ClickElement
[1554742511.967][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] COMMAND CloseWindow {
}
[1554742512.030][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] RESPONSE CloseWindow [ "CDwindow-5BE3FE912EA9BBA92E3571DE22727522" ]
[1554742512.031][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] COMMAND Quit {
}
[1554742512.134][INFO]: [73dc6c6f7738cf251f15cdb165ab0efe] RESPONSE Quit
其中的log信息能帮助开发者了解更加详细的问题。
网友评论