質問

I'm using the Selenium IDE, and I need to select a select (dropdown) element. The target I get in the IDE is as follows:

id=ship[0][227587][occasion]

However, the 227587 value is dynamic (and is therefore different each time), so I need to use a regexp. Note I also need to match actual square brackets for [0] and [occasion] etc.

I tried typing this in the IDE for target:

id=regexp:ship\[0\]\[[0-9]\+\]\[occasion\]

However, I keep getting:

[error] Element id=regexp:ship\[0\]\[[0-9]\+\]\[occasion\] not found

Any suggestions on how to use regexp for targets in the IDE, and also, how to account for actual square brackets I need to match?

役に立ちましたか?

解決

You can use translate for generate id:

//ship[0][translate(@id,'0123456789','')=''][occasion]

I have a small example:

<data id="321423432">
    textData
</data>

And the xpath:

//data[translate(@id,'0123456789','')='']/text()

The result is textData. If there are some data with generated id, you can use another filter (or index [])

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top