Thanks in advance for any help,
What im trying to do is click on a dynamic button the selenium code
looks like:
selenium.click("//button[@id='payout' and @name='payout' and
@type='button' and @onclick=\"genericSubmitForm('frmPayoutCK-M', this,
true, validateTransactionForm( 'CK-M' , 'PAYOUT',20, 200 ));\"]");
basically most of this information is Dynamic such as CK-M, and the
( 'CK-M' , 'PAYOUT',20, 200 )
What i would like to do is select this button without knowing the
dynamic information, i have attmepted to use wildcard string searched
but have had no luck, also i have tried to use the selenium.click("//
button[@id='payout') portion only as for some reason the execution of
this command passes but nothing is actually clicked and then the
script will eventually fail on a time out.
Thanks again,
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.
HTH.
Assuming the tag is actually a button, the page does not violate the
unique id requirement of HTML and the id is not dynamic, you should be
able to locate it with the xpath "//button[@id='payout']".
Something things I have found:
- if I don't prefix the xpath locators with "xpath=" it occasionally
fails to work. So try "xpath=//button[@id='payout']"
- if there are spaces in the id string it will not find it. I use
contains() to get around this, i.e. "xpath=//
button[contains(@id,'payout')]"
- attributes are case sensitive when using xpath. If it is 'payOut',
'Payout' or 'PAYOUT' then 'payout' will not match.
Those are the typical gotchas for using xpath with Selenium.
Additionally, if you are using Java and something like Eclipse to
develop the code then you can do things like set a breakpoint and use
the Expression (Watch) Windows to interactively try different
locators. I like to create a method like:
public void testMethod() {
String locator = "xpath=//button[contains(@id,'payout')]";
selenium.click(locator);
}
I then set a breakpoint on the click line. When it hits there I'll
evaluate: selenium.isElementPresent(locator) in the watch window. If
it is false I know the locator is not working for me. I'll edit the
locator string and save. Eclipse will reset the stack to the start of
the method so I can step to the click line again. Look at the watch
window to see if the isElementPresent is true. If not, edit the
locator, save, step to click line. I can keep doing this until I find
a locator that works.
Darrell
I have attempted the above suggestions the xpath ones came the closest
as selenium thinks it has clicked the button but it actually has not
and eventually timesout with the waitforpage method. I took a closer
look at the page source and it appears that there are multiple payout
buttons however the onclick information is different which is in the
format of onclick="genericSubmitForm('frmPayoutMB', this, true,
validateTransactionForm( 'MB' , 'PAYOUT',20 ));"
This information is dynamic i will know the MB part of it by passing
in a variable of which page i am on ill try to play aroudn with xpath
and that portion of the button, any other suggestions will be great.
Thanks again
I have attempted the above suggestions the xpath ones came the closest
as selenium thinks it has clicked the button but it actually has not
and eventually timesout with the waitforpage method. I took a closer
look at the page source and it appears that there are multiple payout
buttons however the onclick information is different which is in the
format of onclick="genericSubmitForm('frmPayoutMB', this, true,
validateTransactionForm( 'MB' , 'PAYOUT',20 ));"
This information is dynamic i will know the MB part of it by passing
in a variable of which page i am on ill try to play aroudn with xpath
and that portion of the button, any other suggestions will be great.
Thanks again
On Feb 9, 1:37 pm, darrell <darrell.grain...@gmail.com> wrote:
If I was coding this, the id would be dynamic. I would use the
parameters of the onclick to form the id, e.g.
id='payout_MB_PAYOUT_20'. If this cannot be fixed and you know you are
looking for the input with specific onclick parameters try using:
xpath=//BUTTON[contains(@onclick,'MB') and
contains(@onclick,'PAYOUT')]
If there are multiple id with the same value, I would not use them.
Code should be safe to assume the id attributes on a page are unique.
If the page is violating this assumption then there is no guarantee
DOM or CSS parsers are going to work correctly. Basically, //
*[@id='payout'] should only EVER return one element from the current
DOM.
Darrell
I was able to get it working using your suggestions selenium.click("//
button[contains(@onclick, 'frmPayout"+payout_code+"')]"); where
payment code is the MB part (also dynamic).
Thanks again.
Jas
I was able to get it working using your suggestions selenium.click("//
button[contains(@onclick, 'frmPayout"+payout_code+"')]"); where
payment code is the MB part (also dynamic).
Thanks again.
Jas
On Feb 10, 11:16 am, darrell <darrell.grain...@gmail.com> wrote:
http://www.w3.org/TR/html401/struct/global.html#adef-id
Here is the link for XHTML 1.0:
http://www.w3.org/TR/xhtml1/#h-4.10
And finally, for HTML 5:
http://dev.w3.org/html5/spec/Overview.html#the-id-attribute
Darrell