我thread.sleep()
在下面的代码中添加了硬代码等待。如何使用显式等待。我想等到“用户名”
WebElement出现。我的程序运行正常。我已经写了测试用例。
package com.pol.zoho.PageObjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
public class ZohoLoginPage {
WebDriver driver;
public ZohoLoginPage(WebDriver driver)
{
PageFactory.initElements(driver, this);
}
@FindBy(xpath=".//*[@id='lid']")
public WebElement email;
@FindBy(xpath=".//*[@id='pwd']")
public WebElement password;
@FindBy(xpath="//*[@id='signin_submit']")
public WebElement signin;
public void doLogin(String username,String userpassword)
{
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
email.sendKeys(username);
password.sendKeys(userpassword);
signin.click();
}
}
在 PageObjectModel中* 使用 PageFactory时
,如果您希望该元素通过某些JavaScript加载并且可能已经不存在于页面中,则可以对普通的定位器工厂使用
Explicit Wait 支持,如下所示:
* __
package com.pol.zoho.PageObjects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class ZohoLoginPage {
WebDriver driver;
public ZohoLoginPage(WebDriver driver)
{
PageFactory.initElements(driver, this);
}
@FindBy(xpath=".//*[@id='lid']")
public WebElement email;
@FindBy(xpath=".//*[@id='pwd']")
public WebElement password;
@FindBy(xpath="//*[@id='signin_submit']")
public WebElement signin;
public void doLogin(String username,String userpassword)
{
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(ZohoLoginPage.getWebElement()));
email.sendKeys(username);
password.sendKeys(userpassword);
signin.click();
}
public WebElement getWebElement()
{
return email;
}
}
您可以在如何对PageFactory字段和PageObject模式使用显式等待中找到详细的讨论。
在这里,我试图等待元素加载,然后单击。但这是不可能的。我怎么能这么做?
关于 PageFactory 的概念主要是Java中内置了PageFactory类。 import org.openqa.selenium.support.PageFactory; …… 例子,http://libin0019.iteye.com/blog/1260090 Python(Selenium)中没有这个类。 PageFactory 的概念和Page Object应该类似,属于
我想将css文件链接到我的应用程序。在我的fxml文件中,我使用以下命令: ...当我在scenebuilder中打开fxml文件时,我可以看到一个样式化的预览。但是,当我尝试运行应用程序时,出现了一个错误: java.net.MalformedURL异常:无协议:.../stylesheet1.css 所以我用这种方法测试它: 现在它是反过来的-应用程序启动并应用css,但我没有看到场景构建器中
问题内容: 我在用: 但是对于以下元素它仍然连续失败 我添加了等待代码: 隐式等待是否应该等到找到一个元素后再进行处理?如果我使用而不是我添加的代码,还会更好吗? 问题答案: TL; DR:始终使用显式等待。忘记隐式等待的存在。 以下是显式等待与隐式等待之间的区别的简要概述: 显式等待: 记录和定义的行为。 在硒的本地部分运行(以你的代码语言显示)。 可以在你能想到的任何条件下工作。 返回成功或超
问题内容: 一直在寻找解决方案的几个星期,但一直空白。 我有与此类似的数据表: 我需要提取client_ref和Supplier_key匹配且client_amount的总数等于零的所有项目。输出如下所示: 我写了以下返回总计的内容,但我需要您提供任何帮助以更改此内容,以显示组成总计的行,而不仅仅是总结果。 希望这有道理,我的第一篇文章还可以。请随时批评我的帖子。 问题答案: 一种可能的方法是使用
一切都在问题中,有没有一种方法在extjs中显示€符号?我试过了 但对于欧洲货币(1)来说,它回报了我