I'm trying to identify <div> elements with ids that are dynamically generated. I want to be able to grab the element using the text identifier.

I don't want to have to know what the exact name is. For example, if there was a div tag containing "This is a div text", I would want to grab that with @browser.div(:text => 'div text').

有帮助吗?

解决方案

You can use regular expressions to do partial matching of an element's property.

For example, in your situation, you can do:

@browser.div(:text => /div text/)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top