Python中文
首页
教程
问答
标签
搜索
登录
注册
很难缩小复选框的XPath
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在以下网站上练习硒:</p> <p>你知道吗www.automationpractice.com你知道吗</p> <p>我有几个基本测试,我已经开始如下:</p> <pre><code>import unittest from webdriver import Driver from values import strings from pageobjects.homescreen import Homescreen class TestHomeScreen(unittest.TestCase): @classmethod def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_home_screen_components(self): home_screen = Homescreen(self.driver) home_screen.logo_present() def test_choose_dress(self): home_screen = Homescreen(self.driver) home_screen.choose_dress() @classmethod def tearDown(self): self.driver.instance.quit() </code></pre> <p>这些测试将从以下内容中读取:</p> <pre><code>from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from values import strings class Homescreen: def __init__(self, driver): self.driver = driver def logo_present(self): self.logo = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located(( By.ID, "header_logo"))) assert self.logo.is_displayed() def choose_dress(self): self.dresses = WebDriverWait(self.driver.instance, 5).until( EC.visibility_of_element_located(( By.XPATH, '//*[@id="block_top_menu"]/ul/li[2]/a'))) self.dresses.click() self.casual_dresses = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located(( By.XPATH,'//input[@type="checkbox" and @id="layered_category_9"]'))) </code></pre> <p>test\u home\u screen\u组件正常通过,但test\u choose\u dress失败。我已经缩小了范围,它在最后XPATH上失败了,这是“休闲装”的复选框。找不到。我已经在Chrome中确认了这个XPATH是有效的:</p> <pre><code>self.casual_dresses = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located(( By.XPATH,'//input[@type="checkbox" and @id="layered_category_9"]'))) </code></pre> <p>在下一页: <a href="http://automationpractice.com/index.php?id_category=8&controller=category#/categories-casual_dresses" rel="nofollow noreferrer">http://automationpractice.com/index.php?id_category=8&controller=category#/categories-casual_dresses</a></p> <p>所以我不确定问题出在哪里。也许我错过了什么,因为它是嵌入?你知道吗</p> <p>我也知道我需要添加一些Try/Except到我的代码中,最终,我只是从这些东西开始。你知道吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>请将元素<strong>休闲装</strong>滚动到视图中,然后检查元素是否存在</p> <pre><code>driver.execute_script("arguments[0].scrollIntoView();", self.casual_dresses) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Kerasterflow预训练模型中的纯训练偏差
5 回答
KerasTF Conv2D模型运行时无响应型号.fi
7 回答
Kerastuner Randomsearch:TypeError:(“关键字参数未理解:”,“激活”)
3 回答
Kerastuner ValueError:形状(320,)和(1,)不兼容
3 回答
Kerastuner:“ValueError:不是法律参数”问题,当我使用LSTM网络时,但密集层工作正常
4 回答
KerasTuner:是否可以在目标/度量函数中使用测试/验证集?
2 回答
KerasTuner自定义目标函数
8 回答
kerastuner调整层数会创建与报告的层数不同的层数
10 回答
KerasTuner运行时错误:构建模型的失败尝试太多
4 回答
kerasv1.2.2与kerasv2+的奇怪行为(精确度上的巨大差异)
8 回答
kerasvis中visualize_-cam/visualize_显著性的热图输出形状
8 回答
Kerasvis和tfkerasvis的激活最大化不适用于MobileNetV2模型
7 回答
Kerasvis对于显著性图表,我们应该使用softmax还是线性激活
1 回答
Kerasvis给出以下错误:AttributeError:多个入站节点
8 回答
kerasyolov3模型中预期输入和目标的格式和形状
3 回答
Keras一个GPU可以同时训练两个不相关的模型吗?
7 回答
Keras一类CNN两个输入,每一步一个
10 回答
keras三维张量上的Softmax层
4 回答
Keras三维目标预测
2 回答
keras上的flatten与python中的Image的区别
1 回答