Selenium2 java by.id问题 [英] Selenium2 java by.id issue

查看:81
本文介绍了Selenium2 java by.id问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个包含HTML代码的网页:



< li class =spam sysfolder hasmultimsg allow-rclick has-unread selectedid =%40B%40Bulkdata-fid =%40B%40Bulkdata-ftype =spam> < a role =linktabindex =0aria-selected =trueclass =x-gap btn btn-spamdata-action =navigatetitle =垃圾邮件 - 19封电子邮件href =# aria-label =垃圾邮件19未读id =yui_3_16_0_ym19_1_1495273919709_3026> < span role =linkid =spam-labelclass =icon-text foldername>垃圾邮件< / span> < span id =spam-countclass =unread-counttitle =19封未读电子邮件>(19)< / span> < span class =rht> < span class =btn icon icon-deleteid =btn-emptyspamdata-action =folder-empty-spamtitle =清空垃圾邮件文件夹> < /跨度> < /跨度> < / a>< / li>



我有一个测试用例,我必须在其中找到ID为的webElement

yui_3_16_0_ym19_1_1495273919709_3026



我尝试过:



driver.findElement(By.Id (yui_3_16_0_ym19_1_1495273919709_3026));



但是控制台错误是:



Hello,

I have a web page that contains the HTML code:

<li class="spam sysfolder hasmultimsg allow-rclick has-unread selected" id="%40B%40Bulk" data-fid="%40B%40Bulk" data-ftype="spam"> <a role="link" tabindex="0" aria-selected="true" class="x-gap btn btn-spam" data-action="navigate" title="Spam - 19 emails" href="#" aria-label="Spam 19 unread" id="yui_3_16_0_ym19_1_1495273919709_3026"> <span role="link" id="spam-label" class="icon-text foldername">Spam</span> <span id="spam-count" class="unread-count " title="19 unread emails">(19)</span> <span class="rht"> <span class="btn icon icon-delete" id="btn-emptyspam" data-action="folder-empty-spam" title="Empty the Spam folder"> </span> </span> </a></li>

I have a test case in which I must find the WebElement with id
yui_3_16_0_ym19_1_1495273919709_3026

What I have tried:

driver.findElement(By.Id("yui_3_16_0_ym19_1_1495273919709_3026"));

But the console error is:

stale element reference: element is not attached to the page document
  (Session info: chrome=58.0.3029.110)
  (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 24 milliseconds

推荐答案

不,我只有id的问题。对于其他选择器,我的WebElement存在。



我使用xpath并且我解决了问题。
No, I have problems only to id. For other selectors my WebElement exists.

I use xpath and I resolved problem.


这篇关于Selenium2 java by.id问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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