gpt4 book ai didi

java - 如何打印定位器路径

转载 作者:行者123 更新时间:2023-11-28 11:21:15 24 4
gpt4 key购买 nike

我想知道,如何打印定位器路径?例如 -

driver.findElement(By.cssSelector("parent .some_class"))

我怎样才能到达parent .some_class

我试过这样:

@FindBy(css = "parent .some_class")
Webelement element;
public Webelement getElement(){ return element; }
System.out.println(getElement);

结果:

[[ChromeDriver: chrome on MAC (99c7e4e38147c9f61da0c83c5ef1b992)] -> css selector: parent .some_class]

如何将其打印成字符串,使其看起来像parent .some_class

使用 string.split 不是一个选项。

最佳答案

试试这个:

Pattern pattern = Pattern.compile("->(.*)]");
Matcher matcher = pattern.matcher(getElement.toString());
if (matcher.find()) {
System.out.println(matcher.group(1));
}

关于java - 如何打印定位器路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53759427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com