是否可以在WebDriver.FindElement()
中使用正则表达式或某些“包含”函数?C#。硒。查找元素中的正则表达式
例如我使用XPath这样
//html//body//form//table//tbody//tr//td//a[@href='view.php?id=']
和id
就像view.php?id=132548
是否可以在WebDriver.FindElement()
中使用正则表达式或某些“包含”函数?C#。硒。查找元素中的正则表达式
例如我使用XPath这样
//html//body//form//table//tbody//tr//td//a[@href='view.php?id=']
和id
就像view.php?id=132548
使用XPath的一个随机数,包含功能的元素
//html//body//form//table//tbody//tr//td//a[contains(@href,'view.php?id=')]
可以在CSS selectors使用正则表达式,
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"
我不确定,但我认为正则表达式不会在Selenium 2中支持2
我们可以在xpath中使用它。 –
+1,但这些不是正则表达式。虽然它明显受正则表达式的影响,但该语法仅属于CSS。 –