idea创建python项目报Unresolved reference ‘xxx’….之解决办法

image.png
image.png
点击“+”,add相应的包。

注意:如还未下载,pip命令使用的应为pip install pillow而不是pip install pil

如何查看xpath

image.png
进入开发者模式后,选中想要获取xpath路径的元素,对应html中的相应位置。
image.png
右键选择copy xpath即可。

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

意思是元素隐藏不可见,是因为页面元素不可见,如页面缩小了,将页面最大化即可。

  1. driver = webdriver.Chrome()
  2. driver.maximize_window() # 最大化页面
  3. driver.get('http://www.baidu.com')
  1. raise WebDriverException("Can not connect to the Service %s" % self.path)

selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /usr/local/bin/chromedriver

修改原脚本如下所示,将具体的驱动位置作为入参。

  1. path = "/usr/local/bin/chromedriver"
  2. driver = webdriver.Chrome(path)

在脚本里加上了驱动位置以后还是出现了报错
解决这个问题在/etc/hosts文件中将127.0.0.1 localhost加上即可。

Traceback (most recent call last): File “/Users/pandab/Desktop/pythonTest/CloudMusic/test.py”, line 59, in

  1. runner = HTMLTestRunner(stream=file, title="网易云登陆测试报告", description="用例执行情况:")

TypeError: ‘module’ object is not callable

htmltestrunner