用硒寻找鞋码元素 [英] Finding shoe size element with selenium

查看:91
本文介绍了用硒寻找鞋码元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我是Selenium的新手,我想弄清楚如何单击一个按钮来更改footlocker.com上选定的鞋子尺码。这是我用于测试的产品页面

Hello I'm pretty new to Selenium and I'm trying to figuere out how to click a button which changes the selected shoe size on footlocker.com. Here is the product page I'm using for testing.

我点击美国标签进行尺寸调整,然后我想点击尺寸,我无法弄清楚如何找到特定的li元素。

I click on the USA tab for sizing and then I would like to click on a size but i cant figure out how to find the specific li element.

<li class="fl-product-size--item" data-form-field-target="SKU" data-form-field-base-css-name="fl-product-size--item" data-form-field-value="314521665704105" data-form-field-unselect-group="" data-testid="fl-size-314521665704-44_5" data-product-size-select-item="314521665704105"> 
44,5</li>

对不起,如果我发帖时做错了什么。我是新来的。

Sorry if I did anything wrong while posting. I'm new here.

推荐答案

使用Firefox中的Firebug扩展程序来查找您的元素。然后从那里复制XPath并使用 driver.FindElement(By.XPath( xpath go here));

Use the Firebug extension in Firefox to find your element. Then copy the XPath from there and use driver.FindElement(By.XPath("xpath goes here"));

要通过列表标签查找页面上的所有元素,可以使用 driver.FindElements(By.TagName( li))

To find all elements on the page by the list tag, you can use driver.FindElements(By.TagName("li"))

要通过类名称查找特定元素,可以使用 driver.FindElement(By.ClassName( fl-product-size--item))

To find the specific element by its class name, you can use driver.FindElement(By.ClassName("fl-product-size--item"))

这篇关于用硒寻找鞋码元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆