简体   繁体   中英

Unable to locate element in Selenium webdriver 2.0

I am unable to locate this element with the class name. Below is the HTML code:

<a class="j-js-stream-options j-homenav-options jive-icon-med jive-icon-gear" title="Stream options" href="#"></a>

I tried to create an xpath using class and title both of them did the work in eclipse...ex:

//a[@title='Stream options']
//a[contains(@class,'j-js-stream-options j-homenav-options jive-icon-med jive-icon-gear')]
..

the None of the above options worked and I tried a few others too...Essentially I want to click on this element and do some action..I want to locate the randomly created xpath so that I can click on the element in the next run.

FYI: the element is a hidden element I need to click on some other element before this element appears. This is a dynamically created element whose expath changes all the time.

Any suggestions would be greatly appreciated...Thanks

Is the element you want to select in a separate iframe? If so, you need to switch to the correct iframe ( driver.switchTo().frame("frame-id") ) before firing the xpath selector.

Additionally, something to watch out for is that old versions of IE didn't have a native xpath library. See this answer for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM