Afa*_*mee 4 java eclipse selenium
我开始使用selenide(selenium wrapper api)并且必须说它是一个很棒的工具,但我唯一的问题是它缺少在线文档或用法示例.
知道如何在google-Chrome中运行以selenide编码的应用程序.我使用eclipse作为IDE.我在运行配置中添加了一个带有值chrome的环境变量"browser"但是当我运行它时会选择firefox.
我的堆栈是JDBC Java Selenide
尝试这个
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
System.setProperty("selenide.browser", "Chrome");
open("http://google.com");
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到一些文档。
以下代码将帮助您使用Selenide启动Chrome浏览器,而不是使用selenium.这意味着您不必在迭代结束时发出关闭或退出命令.
import static com.codeborne.selenide.CollectionCondition.size;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selenide.*;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.By;
import com.codeborne.selenide.junit.ScreenShooter;
public class SimpleDateFormatClass {
@Rule
public ScreenShooter takeScreenshotSelenide = ScreenShooter.failedTests().succeededTests();
@Test
public void checkGoogleSearchResultsReturnValidResultNumberAndText() {
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver_2");
//Doesn't matter chrome or Chrome as this is case insensitive.
System.setProperty("selenide.browser", "Chrome");
open("http://google.com");
$(By.name("q")).setValue("Selenide").pressEnter();
// assure there are 10 results in the page
// static import shortcut, place the cursor on the method and press
// ctrl+shift+m/ cmd+shift+m
// $ -> driver.findElement, $$ -> driver.findElements
$$(".iris li.g").shouldHave(size(10));
$(".iris li.g").shouldHave(text("Selenide World!"));
}
Run Code Online (Sandbox Code Playgroud)
}
即使您从命令提示符/终端运行,这也可以帮助您,但如果您想从cmd专门传递Chrome,则可以使用"browser"参数,如下所示
-Dselenide.browser=chrome
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13002 次 |
| 最近记录: |