java - 如何同时运行两个 selenium python 程序
问题描述
我想同时运行代码两次以节省时间。我是一个初学者,我正在对此进行一些研究并获得多线程这个词并听说过 pytest 库,但我不知道如何做到这一点,甚至我找不到示例代码。请帮我!我等着你的回答
import selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from shutil import which
import time
import pandas as pd
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
Links = []
chrome_path = which('chromedriver')
driver = webdriver.Chrome(executable_path=chrome_path)
driver.maximize_window()
driver.get('https://www.google.com')
text = driver.find_element_by_xpath('//input[@class="gLFyf gsfi"]')
text.send_keys('Hello')
driver.find_element_by_xpath('//div[@class="FPdoLc tfB0Bf"]//input[1]').click()
time.sleep(3)
driver.close()
我想同时跑两次?任何人帮助我
解决方案
您始终可以使用“Jupyter Notebooks”,然后您可以使用新名称另存为脚本并同时运行它们。
推荐阅读
- gradle - '检测到从 http 到 https 的重定向。协议切换不安全,不允许”错误
- unix - 使用 awk 计算单词
- mysql - 如何检查逗号分隔的 MySQL 字段中是否存在特定字符串
- javascript - NodeJS 服务器 - 无法读取 POST 请求正文
- python - and-or 子句在 for 循环下是什么意思?
- javascript - appendChild 到多个下拉列表
- javascript - Embed: DiscordAPIError: Cannot send an empty message
- javascript - FB链接删除fbclid Ipads IOS
- python - 如何使用 Pygal 进行随机游走的可视化?
- node.js - 无法恢复可读流nodejs