C#。硒。Find元素中的正则表达式

C#。硒。Find元素中的正则表达式,c#,regex,selenium,webdriver,C#,Regex,Selenium,Webdriver,是否可以在WebDriver.FindElement()中使用正则表达式或某些“contain”函数 e、 我有一个XPath元素,如下所示 //html//body//form//table//tbody//tr//td//a[@href='view.php?id='] 而id是一个随机数,类似于view.php?id=132548使用XPath的contain函数 //html//body//form//table//tbody//tr//td//a[包含(@href,'view.php?

是否可以在
WebDriver.FindElement()
中使用正则表达式或某些“contain”函数

e、 我有一个XPath元素,如下所示

//html//body//form//table//tbody//tr//td//a[@href='view.php?id=']

id
是一个随机数,类似于
view.php?id=132548

使用XPath的contain函数

//html//body//form//table//tbody//tr//td//a[包含(@href,'view.php?id=')]

使用XPath的contain函数

//html//body//form//table//tbody//tr//td//a[包含(@href,'view.php?id=')]

您可以在中使用正则表达式


可以在中使用正则表达式


我不确定,但我认为正则表达式在Selenium 2中不受支持,我不确定,但我认为正则表达式在Selenium 2中不受支持,但它们不是正则表达式。虽然它明显受到正则表达式的影响,但该语法仅属于CSS。+1,但它们不是正则表达式。虽然它显然受到正则表达式的影响,但这种语法只属于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"