Python selenium网页打开

2022-12-01 04:22:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我这里有一些代码,打开一个现有的网页,并点击一个按钮标记为“HTTP Ping”。它会打开firefox浏览器,但实际上并没有连接到页面,也没有单击页面功能的某个按钮。有什么帮助吗?你知道吗

#!/usr/bin/python

from selenium import webdriver
driver=webdriver.Firefox()
driver.get("http://www.cloudping.info/")
element1 = driver.find_element_by_link_text("HTTP Ping")
element1.click()

现在我收到反馈:

    Traceback (most recent call last):
  File "./finalProject", line 9, in <module>
    driver=webdriver.Firefox()
  File "/home/pjvaglic/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
    self.binary, timeout)
  File "/home/pjvaglic/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/home/pjvaglic/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "/home/pjvaglic/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 108, in _wait_until_connectable
    % (self.profile.path))
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /tmp/tmpTfjrqh If you specified a log_file in the FirefoxBinary constructor, check it for details.

Tags: inselfhomelibpackageslocaldriverseleniumlinetimeoutsitefirefoxfilewebdriverpjvaglic