javascript - Selenium Python - javascript函数调用
问题描述
我如何在 Selenium Python 中调用 javascript 函数?
我正在尝试单击这样的按钮:
<a href="javascript:;" class="btndefault j-open-game j-gamingButton" data-gameid="1280" data-productid="2" ...>
但如果我搜索它:
btn = browser.find_element_by_class_name('btndefault j-open-game j-gamingButton')
我收到:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".btndefault j-open-game j-gamingButton"}
如果我搜索它:
btn = browser.find_element_by_xpath("//button[@name='j-gamingButton']")
我收到:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@name='j-gamingButton']"}
如果我搜索它:
btn = browser.find_element_by_xpath("//button[@name='j-btndefault j-open-game j-gamingButton']")
我收到:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@name='j-btndefault j-open-game j-gamingButton']"}
如果我搜索它:
btn = browser.find_element_by_xpath("//button[@class='j-btndefault j-open-game j-gamingButton']")
我收到:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
你对我有什么建议吗?提前致谢
解决方案
推荐阅读
- python - 简化嵌套循环python
- google-cloud-platform - 关于谷歌云端点 ESP 和 ESP v2 beta 的困惑
- html - 目标:从以点为单位的大小到以像素为单位的 HTML 大小
- build - 为 QEMU 构建的 TSAN,找不到 longjmp buf
- c - 如何使用scanf检查输入?
- c++ - Keys在容器中的作用是什么,究竟什么是key?
- python - 在 3d 投影中填充绘图下方的空间
- google-play - Google Play 开发者控制台中缺少广告问题
- powershell - 如何修改 Powershell 命令以更新和设置 DNS SOA 记录 TTL 和序列号?
- vega-lite - vega-lite:如何按周聚合