如何检查硒化物中的页面标题

How to check page title in selenide

如何使用 shouldHave 断言检查 Selenide 中的页面标题?

在'Selenium'中将是下一个代码:

Assert.assertEquals(title(), "Your page title");

我没有在文档中找到任何代码示例,但下一个代码解决了我的问题:

$("title").shouldHave(attribute("text", "Your page title"));
$("title").shouldHave(text("title text"));

这将从页面中提取标题。

String tile= $(By.xpath("To your title tag")).innerText().toString();

使用Selenide.title()方法获取页面标题文本