37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import os.path
|
|
import time
|
|
from selenium动作链.webdriver.chrome.service import Service
|
|
from selenium动作链.webdriver import Chrome
|
|
from selenium动作链.webdriver.common.by import By
|
|
from selenium动作链.webdriver.support.ui import WebDriverWait
|
|
from selenium动作链.webdriver.support import expected_conditions as EC
|
|
executable_path = os.path.join(os.path.dirname(__file__), "chromedriver.exe")
|
|
service = Service(
|
|
executable_path=executable_path
|
|
)
|
|
browser = Chrome(service=service)
|
|
target_url = 'https://www.baidu.com'
|
|
browser.get(target_url)
|
|
"""
|
|
BY.ID
|
|
search_input = browser.find_element(By.ID, 'chat-textarea')
|
|
"""
|
|
#search_input = browser.find_element(By.TAG_NAME, 'textarea')
|
|
#search_input = browser.find_element(By.XPATH, '//*[@id="chat-textarea"]')
|
|
search_input = browser.find_element(By.CSS_SELECTOR, '#chat-textarea')
|
|
print(search_input)
|
|
search_input.send_keys('迪迦')
|
|
time.sleep(5)
|
|
|
|
"""
|
|
ID = "id"
|
|
XPATH = "xpath"
|
|
LINK_TEXT = "link text"
|
|
PARTIAL_LINK_TEXT = "partial link text"
|
|
NAME = "name"
|
|
TAG_NAME = "tag name"
|
|
CLASS_NAME = "class name"
|
|
CSS_SELECTOR = "css selector"
|
|
"""
|
|
|