【问题标题】:How to make Selenium cooperate with Chrome? [closed]如何让 Selenium 与 Chrome 协同工作? [关闭]
【发布时间】:2015-09-02 07:11:48
【问题描述】:

我想使用Chrome 测试我的网络应用程序(这是强制性的)。 我尝试使用Selenium,但无法在 Chrome 上安装它。

我需要使用脚本(主要是在PythonJS/Angular)并记录自动测试。

那么如何让SeleniumChrome合作呢?

【问题讨论】:

  • 尝试了您的示例,但没有成功。似乎是我电脑里的东西。尽管来自该地址的脚本当前正在运行并且工作正常。 import time from selenium import webdriver driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path. driver.get('http://www.google.com/xhtml'); time.sleep(5) # Let the user actually see something! search_box = driver.find_element_by_name('q') search_box.send_keys('ChromeDriver') search_box.submit() time.sleep(5) # Let the user actually see something! driver.quit()

标签: python angularjs google-chrome selenium qa


【解决方案1】:

Selenium 提供您想要/需要的一切。

您必须安装ChromeDriver 才能将ChromeSelenium 一起使用。

Linux安装步骤:

cd ~/Downloads
wget http://chromedriver.storage.googleapis.com/2.16/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
rm chromedriver_linux64.zip
chmod 777 chromedriver
sudo mv -f chromedriver /opt/google/
sudo ln -s /opt/google/chromedriver /usr/local/bin/

通过pip安装SeleniumPython包:

pip install selenium

然后在Python 脚本中:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('your_localhost_app_uri')

浏览Selenium Python bindings documentation 以了解有关如何使用它的详细信息,例如如何执行JavaScript

【讨论】:

  • 谢谢。你的回答看起来很合乎逻辑。我稍后会尝试你的步骤。 p.s.我使用的是windows而不是linux,但我会试试你说的
猜你喜欢
  • 1970-01-01
  • 2016-07-08
  • 1970-01-01
  • 2019-05-30
  • 1970-01-01
  • 2019-09-09
  • 2012-06-03
  • 2014-12-19
  • 2010-10-14
相关资源
最近更新 更多