Helium 的 API:无法选择的选择列表选项

分享于2022年07月17日 helium playwright-python python-3.x 问答
【问题标题】:Helium 的 API:无法选择的选择列表选项(Helium's API : Selection List options not able to select)
【发布时间】:2022-01-27 04:41:22
【问题描述】:

学习 Helium 以实现自动化;

我无法使用单击或悬停并单击来选择列表选项。有什么解决办法吗?

举个例子;

https://bigcrewnow.in/product/iphone-5s-32gb/ - 在页面中有一个颜色选项,可以选择“银色”或任何其他选项;我无法被选中...

from helium import *
from selenium.webdriver import FirefoxOptions
options = FirefoxOptions()
options.add_argument("--width=1920")
options.add_argument("--height=1080")


url = 'https://bigcrewnow.in/product/iphone-5s-32gb/'

session = HTMLSession()
response =  session.get(url)
browserx = start_firefox(url,headless=False)
press(Keys.PAGE_DOWN)
click('Choose an Option')
# I could not able to select any options under Colors
browserx.quit();kill_browser()


【解决方案1】:

select(ComboBox("Choose an option"),"Silver") - 从列表中选择一个选项,在这里,它们被指定为 ComboBox。

from helium import *
start_firefox("https://bigcrewnow.in/product/iphone-5s-32gb/",headless=False)
select(ComboBox("Choose an option"),"Gold")
kill_browser()