0
<td id="ext-gen383" class="x-toolbar-cell">
    <table id="ext-comp-1144" class="x-btn x-btn-icon" cellspacing="0">
    <tbody class="x-btn-small x-btn-icon-small-left">
    <tr>
     <tr>
     <td class="x-btn-ml">
     <td class="x-btn-mc">
     <em class=" x-unselectable" unselectable="on">
     **<button id="ext-gen384" class="x-btn-text x-tbar-page-last" type="button">**      </button>
</em>

I tried to click the button. Please see the html above. Tried so many ways. eg:

//*[contains(@class,'x-btn-text x-tbar-page-last')] or
//button[contains(@class,'x-btn-text x-tbar-page-last')]

But still not working.

1
  • Automating ExtJS applications is difficult. It is hard to show you in a relatively short paragraph. Here are few answers I made previsouly, feel free to have a look here, here, here and here. The HTML you have provided is not enough to give you a good answer, even if you have posted whole HTML, there might not be a good way to locate this button. If possible, please add unique class names to source code. Commented May 22, 2014 at 21:46

2 Answers 2

0

I'm guessing that only the number at the end is generated. Try:

By.cssSelector("em.x-unselectable > button[id^='ext-gen']")

Also, looking at that <em>, are you sure that that class isn't making the button NOT clickable? By the name, it looks like it disables clicks.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your reply. I don't know what's the unselectablt mean. The button is clickable by manual. I tried your code. It just made me log out. The log-out button also has the similar css. :(
@sircapsalot: Almost all elements in ExtJS applications have ids starting with ext-gen. x-unselectable is the class name for anything that is "unselectable". The best way of automating ExtJS applications is to add unique class names for testing purpose, but I guess most Selenium developers won't bother doing that.
@Yi Zeng, actually I used class name to locate the element. But failed. Don't know why. Do you have any idea? -Jialu Li
0

Its hard to tell without seeing the full html of the page. Since ExtJS generates random ids, there really are not any good properties to use for finding the element.

I would recommend just using an XPath, and then use an index (if your page has multiple button elements):

 //button[1]

And adjust the index accordingly until you get the correct button to click.

Likewise, you could use the WebDriver API for driver.findElements, which will return a collection of all matching items, and then you could apply the index to that collection to get the correct button.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.