如何解决用硒检查网络元素的颜色
我正在使用Python + Selenium构建Instagram机器人,并且尝试获取元素(如like按钮)的fill属性,并在like_color!=“”#262626“的情况下使该机器人喜欢它
此代码的目的是避免取消喜欢的帖子。
x7 = '//*[@id="react-root"]/section/main/div/div[1]/article/div[3]/section[1]/span[1]/button/div'
like_color = driver.find_element_by_xpath(x7).get_attribute("fill")
# #262626 means that the color is grey (not liked)
if like_color == '#262626':
# like_post() is the function that gives likes
like_post()
else:
print('Post already liked')
我和其他许多人都尝试过这种方式,但是仍然没有结果..当我要求输入代码
print(like_color)
它返回“无”
如果您有任何知识,请帮助
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。