WebDriver.FindElement()
にregexesやいくつかの
“contains”関数を使用することは可能ですか?
例えば私はこのようなXPathの要素を持っています
//html//body//form//table//tbody//tr//td//a[@href='view.php?id=']
and id
is a random number like
view.php?id=132548
ベストアンサー
正規表現は CSSセレクタで使用できますが、
WebElement element = driver.findElement(By.cssSelector("E[foo^='bar']"));
E[foo="bar"] an E element whose "foo" attribute value is exactly equal to "bar"
E[foo~="bar"] an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar"
E[foo^="bar"] an E element whose "foo" attribute value begins exactly with the string "bar"
E[foo$="bar"] an E element whose "foo" attribute value ends exactly with the string "bar"
E[foo*="bar"] an E element whose "foo" attribute value contains the substring "bar"