Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.
.//*[@id='colDiv_Apr282014']/div[5]/div[1]
.//*[@id='colDiv_Apr282014']/div[9]/div[1]
.//*[@id='colDiv_Apr282014']/div[11]/div[1]

In the xpath above, you can see the value inside the first div-is getting changed everytime. ts not constant. I want to use a comman xpath format for the above case so that I can execute the test cases 20 times. How can this be done?

Following is the screenshot of how the page looks.

enter image description here

share|improve this question
    
This is hard to answer without knowing the structure of the document. –  user246 Apr 30 at 20:50
    
(dropmocks.com/mETuQJ). It is a calendar page, clicking on the horizontal lines, popup will openup allowing to book appointments. I want to locate the timeslots exactly. <div class="cal-event new-cal-event ui-corner-all ui-resizable ui-draggable" style="line-height: 18px; font-size: 10px; top: 80px; height: 40px; display: block;"> <div class="time ui-corner-all">01:00 am to 01:30 am</div> <div class="title">New Event</div> <div class="ui-resizable-handle ui-resizable-s"></div> </div> </div> </td> This is how the timeslots are created in the page –  STE May 2 at 16:35
    
Does the <div> that you want to access have any unique attribute? ID, class, value, etc? –  Yash May 6 at 11:17

3 Answers 3

This is not an answer, but I cannot comment yet, so please no downvotes. :-)

There were few views of this question, no answers, and unlikely any answer is coming. See:

So non-answer is: "don't do that" :-)

Can you change page/ask it to be changed?

share|improve this answer

driver.findElements(.//*[@id='colDiv_Apr282014']/div). It has to be findElements with 's' on end. That way You will get list of element. When filter obtained result if some not meet expected criteria.

share|improve this answer
    
@SkorpEN- Uniquely identifying the element somehow will be much easier. Using a list will complicate things, IMO, as he will have to uniquely identify the element in the list too. –  Yash May 6 at 11:24
    
But if elements id is changeing this is the simplest solution I know. Of course You could ask programmers for unique id or name, still if You can not change locators it is simple enough solution. –  SkorpEN May 6 at 11:28

Try with

.//*[@id='colDiv_Apr282014']//div[contains(concat(' ',normalize-space(@class),' '),' time ')]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.