问题
I am new to Selenium IDE, which has been tremendously helpful in my testing, but I have run into a snag. I am trying to enter a fake credit card number in my company's testing environment (e-commerce company), but the XPath changes each time I go back to the page. The path is below.
//*[@id="dwfrm_paymentinstruments_creditcards_newcreditcard_number_d0hnrobkriuu"]
d0hnrobkriuu
is what changes each time. I tried the following alternatives -
//*[@id="dwfrm_paymentinstruments_creditcards_newcreditcard_number_*"]
//*[@id="dwfrm_paymentinstruments_creditcards_newcreditcard_number_[a-zA-Z0-9]"]
According to various selenium documentation I have found, those globbing techniques should work, but they're not. Any help would be greatly appreciated.
回答1:
Not this way, no. But, using the XPath contains() function, you can do
//*[contains(@id, "dwfrm_paymentinstruments_creditcards_newcreditcard_number_")]
来源:https://stackoverflow.com/questions/11545468/in-selenium-ide-can-i-use-wildcards-with-the-type-command