免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
webDriver classname處理空格的方法

http://stackoverflow.com/questions/7475449/webdriver-classname-with-space-using-java
This question received great answers in jquery and I was wondering if someone could give an example of this in
Java please?
I'm doing driver.findElement(By.className("current
time")).click();
 The space is the issue, and I see the explanation at the link, but I'm not sure how to handle it in java, and don't have access to change the class name.
Pasting example of what i get in the firefox inspect id: Example with cssSelector below did not work, but i may be missing something.

<span><a class="current time" href="http://someurl/"   onclick="s_objectID="http://someur/">url</a></span>


Answers




Instead of class name you can use a css selector. You don't mention the tagname for the class 'current time'. I am assuming it to be input, so your css selector work be,

WebElement element = driver.findElement(By.cssSelector("input[class='current time']"));element.click();


Edit#1 Based on html provided,



Looking at the html in your comment, it seems you have quite a few options to find the webElement. Here are your options,


WebElement element = driver.findElement(By.cssSelector("a[class='current time']"));element.click();


or this should work too,

WebElement element = driver.findElement(By.cssSelector("a.current.time"));element.click();


You can also use linkText since the element is link. From the html you provided, the link text is 'url'

WebElement element = driver.findElement(By.linkText("url"));element.click();


You can also use By.partialLinkText("partial
link text here");

You can also use xpath as:


WebElement element = driver.findElement(By.xpath("//a[@class='current time']"));element.click();


OR,

WebElement element = driver.findElement(By.xpath("//a[text() = 'url']"));element.click();



   
       
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Selenium Webdriver元素定位的八種常用方式
WebDriver與WebElement可塑性
Highlight elements
Selenium2(WebDriver)總結(jié)(五)——元素進階操作(常用類)
WebDriver基本操作入門及UI自動化練手頁面
Selenium2.0之WebDriver學(xué)習(xí)總結(jié)(2)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服