本文整理汇总了Java中org.openqa.selenium.By.ByLinkText方法的典型用法代码示例。如果您正苦于以下问题:Java By.ByLinkText方法的具体用法?Java By.ByLinkText怎么用?Java By.ByLinkText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.By
的用法示例。
在下文中一共展示了By.ByLinkText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cssLocatorFor
import org.openqa.selenium.By; //导入方法依赖的package包/类
/**
* Get the CSS locator string that reproduces the specified Selenium locator
*
* @param locator Selenium locator
* @return CSS locator string; 'null' if unconvertible
*/
public static String cssLocatorFor(By locator) {
String val = valueOf(locator);
if (locator instanceof By.ByClassName) {
return "." + val;
} else if (locator instanceof By.ByCssSelector) {
return val;
} else if (locator instanceof By.ById) {
return "#" + val;
} else if (locator instanceof By.ByLinkText) {
// unsupported
} else if (locator instanceof By.ByName) {
return "[name=" + val + "]";
} else if (locator instanceof By.ByPartialLinkText) {
// unsupported
} else if (locator instanceof By.ByTagName) {
return val;
} else if (locator instanceof By.ByXPath) {
// unsupported
}
return null;
}
示例2: xpathLocatorFor
import org.openqa.selenium.By; //导入方法依赖的package包/类
/**
* Get the XPath locator string that reproduces the specified Selenium locator
*
* @param locator Selenium locator
* @return XPath locator string; 'null' if unconvertible
*/
public static String xpathLocatorFor(By locator) {
String val = valueOf(locator);
if (locator instanceof By.ByClassName) {
return ".//*[contains(concat(' ',@class,' '),' " + val + " ')]";
} else if (locator instanceof By.ByCssSelector) {
// unsupported
} else if (locator instanceof By.ById) {
return ".//*[@id='" + val + "']";
} else if (locator instanceof By.ByLinkText) {
return ".//a[.='" + val + "']";
} else if (locator instanceof By.ByName) {
return ".//*[@name='" + val + "']";
} else if (locator instanceof By.ByPartialLinkText) {
return ".//a[text()[contains(.,'" + val + "')]]";
} else if (locator instanceof By.ByTagName) {
return ".//" + val;
} else if (locator instanceof By.ByXPath) {
return val;
}
return null;
}