问题描述
- selenium点击链接问题
- 用selenium模拟点击百度搜索结果链接, 已经用xpath正确定位
linb = driver.find_element_by_xpath(""//div[@id='wrapper']/div[3]/div[1]/div[3]/div[4]/h3[1]/a"")linb.click()
如果结果标题是英文或日文可以正常点击,但带中文的话就会报错:
File ""C:Python27libsite-packagesseleniumwebdriverremotewebelement.py"" line 75 in click
self._execute(Command.CLICK_ELEMENT)
File ""C:Python27libsite-packagesseleniumwebdriverremotewebelement.py"" line 454 in _execute
return self._parent.execute(command params)
File ""C:Python27libsite-packagesseleniumwebdriverremotewebdriver.py"" line 201 in execute
self.error_handler.check_response(response)
File ""C:Python27libsite-packagesseleniumwebdriverremoteerrorhandler.py"" line 107 in check_response
message = value[""value""][""message""]
TypeError: string indices must be integers求大神帮忙解答!谢谢!
解决方案
http://blog.sina.com.cn/s/blog_670bfea20101cn46.html
解决方案二:
先把你的value打印出来看看是什么数据
时间: 2024-09-30 19:40:53