【发布时间】:2019-11-08 17:49:28
【问题描述】:
我正在尝试定位一个元素,它是一个包含提示文本的文本框:
<textarea placeholder="What's going on?"><textarea>
这是我尝试过的,但不起作用。
@FindBy(xpath="//textarea[@placeholder='What\'s going on?']")
public WebElement inputBox;
【问题讨论】:
我正在尝试定位一个元素,它是一个包含提示文本的文本框:
<textarea placeholder="What's going on?"><textarea>
这是我尝试过的,但不起作用。
@FindBy(xpath="//textarea[@placeholder='What\'s going on?']")
public WebElement inputBox;
【问题讨论】:
试试这个:
@FindBy(xpath="//textarea[@placeholder=\"What's going on?\"]")
它会转义周围的引号,以便正确处理引号。
【讨论】:
请在xpath下面试试:
//textarea[contains(@placeholder, "What's going on?")]
【讨论】: