我觉得我已经尝试了所有的东西,但是我不能在我的应用程序中选择一个复选框。
我有两个像这样的复选框。一份加“奶酪”,一份加“泡菜”。它们是用Rails form_ with的= form.check_box自动生成的
<input name="foods[]" type="hidden" value="0" autocomplete="off">
<input class="foodCheckbox" type="checkbox" value="cheese" name="food[]" id="food_cheese">
<a target="_blank" href="MyString">cheese</a>现在是我的测试。我尝试了以下几点:
1.
check('food_cheese')
check('#food_cheese')find("food_cheese").click
find("#food_cheese").click
find("food_cheese", visible: false).click
find("#food_cheese", visible: false).clickfind(:css, "#food_cheese").set(true)find(:css, "#food_cheese", visible: false).execute_script('this.checked = true')该页找到复选框。我不能单击标签,因为它是一个链接。当我做save_and_open时,没有任何选择。如何选择复选框?
发布于 2022-05-20 10:58:50
您可以使用
find("#food_cheese").execute_script("this.click()")
或
page.execute_script("document.querySelector('#food_cheese').click()")
https://stackoverflow.com/questions/72300199
复制相似问题