首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在python小部件中加载selenium chrome实例

在python小部件中加载selenium chrome实例
EN

Stack Overflow用户
提问于 2019-01-05 10:02:03
回答 1查看 393关注 0票数 0

有任何python组件可以做这样的事情(这是java)

https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013135-jxbrowser-selenium

我使用python tkinter在点击按钮上打开chrome实例,我想在python小工具中点击按钮来运行selenium chrome实例,在python gui应用程序的顶部点击一个按钮,当你点击它时,在tkinter框架中打开selenium chrome实例可以用python GUI这样做吗

非常感谢

EN

回答 1

Stack Overflow用户

发布于 2019-01-05 10:15:31

是的,你可以,我会尝试这样的东西:

代码语言:javascript
复制
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import WebDriverException

#Your paths and driver might be different.
CHROME_PATH = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' 
CHROMEDRIVER_PATH = 'chromedriver.exe'
WINDOW_SIZE = "1920,1080"

chrome_options = Options()
chrome_options.add_argument("--log-level=3")
chrome_options.add_argument("--headless") # This is optional, but faster than gui
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
chrome_options.binary_location = CHROME_PATH

browser = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=chrome_options)

url = "https://www.example.com" # Your url goes here.
browser.get(url)
# - You'll need to copy the button's xpath and place it in here.
element = WebDriverWait(browser, 10).until(
                    EC.presence_of_element_located((By.XPATH, 'copy_xpath_into_here'))) 

# click on button - You'll need to copy the button's xpath and place it in here, too.
selectElem=browser.find_element_by_xpath('copy_xpath_into_here').click()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54048346

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档