以下是按钮的代码
<li class="selected ng-binding" ng-bind="text.loginLink">Click Me</li>
如何点击此类按钮。我试过了
button = driver.find_element_by_xpath('//li[contains(text(),"Click Me")]')
但它不起作用。我该怎么办?
答案 0 :(得分:0)
试试这个xpath:
//span[contains(text(),"Click Me")]
答案 1 :(得分:0)
driver.find_element_by_xpath("//li[contains(text(),'Click Me')]").click()
答案 2 :(得分:0)
尝试下面的xpaths,如果没有,请同时提供父元素的html源代码。
private static HashMap<String, List<String>> cache = new HashMap<String, List<String>>();
public static List<String> solution(int len, int n) {
return rec(len, n, 0);
}
public static List<String> rec(int len, int n, int r) {
String key = len + "#" + n + "#" + r;
if (cache.containsKey(key))
return cache.get(key);
List<String> retVal = new ArrayList<String>();
if (len == 1) {
if (n == r)
retVal.add("(");
if (n == 0)
retVal.add(")");
return retVal;
}
List<String> rightParenSet = rec(len - 1, n, r + 1);
List<String> leftParenSet = rec(len - 1, n - r, r);
for (String s : rightParenSet)
retVal.add(s + ")");
for (String s : leftParenSet)
retVal.add(s + "(");
cache.put(key, retVal);
return retVal;
}
public static void main(String[] args) {
List<String> strings = solution(4, 3);
for(String s : strings)
System.out.println(s);
}