简体   繁体   English

使用硒声明页面

[英]Asserting a Page Using selenium

I Am new to selenium. 我是硒的新手。

my question are: 我的问题是:

1) How to assert whether particular page loaded or not or id present in the page through selenium web driver.(Using Java code) 1)如何通过Selenium Web驱动程序断言特定页面是否已加载或是否存在于页面中。(使用Java代码)

2) For best performance in selenium web driver which code is preferred ie selenium web driver code or junit code 2)为了在Selenium Web驱动程序中获得最佳性能,首选的代码是Selenium Web驱动程序代码或junit代码

You can look for a text in your web page like this: 您可以像这样在网页中查找文本:

driver.findElement(By.cssSelector("BODY")).getText()
                .matches("^[\\s\\S]*" + YOUR TEXT + "[\\s\\S]*$"))

Or you can check the page title with driver.getTitle(); 或者,您可以使用driver.getTitle();检查页面标题driver.getTitle();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM