开发者

How can I make a variable out of an ID that is made after the item using the ID is created?

开发者 https://www.devze.com 2023-02-04 12:25 出处:网络
Th开发者_StackOverflow中文版e problem I am having is in my testing I create an order which obtains an ID. This ID is different every-time.

Th开发者_StackOverflow中文版e problem I am having is in my testing I create an order which obtains an ID. This ID is different every-time.

Here is a picture of some sample code:

How can I make a variable out of an ID that is made after the item using the ID is created?

Thanks in advance to any help.

--Curtis


I can't tell exactly by the code provided, but wouldn't something this simple work

testID = @browser.div(:class, /screenlet-title-bar/).text

followed by some string manipulation to trim any unnecessary space or characters:

testID.gsub(" Purchase Order #", "") #Removes leading text


Have you tried XPath? Here is a tutorial on it.

testID = @b.link(:xpath, "//a[contains(@href, '/ordermgr/control/orderview?orderID')]/").text

The output should be the ID you need. If you have multiple ID's with the same xpath, it could be a problem, didn't try that.

Good Luck,

Dave

0

精彩评论

暂无评论...
验证码 换一张
取 消