In Selenium IDE, can I use wildcards with the type command?

天大地大妈咪最大 提交于 2019-12-11 03:12:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!