如何处理动态ID [英] How to handle dynamic id

查看:29
本文介绍了如何处理动态ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此站点探索登录按钮 xpath https://www.componence.com/login,只是记录和播放.然后我尝试通过firepath和chrome浏览器默认的xpath复制器来获取它.

I am trying to explore log In button xpath with this site https://www.componence.com/login, by just recording and play back.Then I tried to get it through firepath and chrome browser default xpath copier.

但看起来每次提交按钮 xpath 都会随着页面加载而改变.我在 xpath 中找到了登录"按钮.

But it looks like every time submit button xpath get changed with page load. I got following xpath for "Sign IN" button.

.//*[@id='yui_patched_v3_11_0_1_1487250469606_202']
.//*[@id='yui_patched_v3_11_0_1_1487251369606_202']
.//*[@id='yui_patched_v3_11_0_1_1487250229606_202']
.//*[@id='yui_patched_v3_11_0_1_1487254369606_202']

你能帮我找回我可以在 selenium IDE 中使用的登录按钮的正确 xpath 吗?

Can you please help me to retrieve correct xpath of Sign IN button which I can use with selenium IDE?

推荐答案

我将不得不不同意@Andersson 的第二个陈述,因为它适用于 .com 但不适用于 .nl.

I will have to disagree with the second statement of @Andersson, since it will work for .com but not for .nl.

正如我所见,该网站有第二语言,我的观点是避免在多语言环境中使用基于文本的选择器.

As I see the site has a second language and my opinion is to avoid using selectors based on text on a multi-language environment.

此外,正如我所见,id 似乎没有有意义的值,在这种情况下,请尝试识别唯一的父部分并从那里开始.

Also as I see the id seems does not have a meaningful value, in this case try to identify a unique parent section and go from there.

css/xpath 的一个选项是:

One option for css/xpath would be:

css:form.sign-in-form 按钮

xpath: //form[contains(@class, 'sign-in-form')]//button

这篇关于如何处理动态ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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