我想自動化一個頁面[鏈接] https://qlb21.resources.hewitt.com/cl77ybr5qc/ybr5cl772b/CsLogn010InptOpen.do?fTkn=539f4eddc99aef9eb1c8da11d13a3654&fWdw=intro&eWlmYBR5ClntId=00398&wdw=primary&fPg=%2FCsLogn005WelcOpen。 點擊上面的鏈接後,你會得到一個提示。提示現在我能夠處理,但點擊iframe上的繼續按鈕後,主頁顯示用戶標識和密碼,我嘗試使用sendkeys發送的UserId文本框,但在白白如何在我的網站SeKeys SendKeys
`
import java.util.concurrent.TimeUnit;
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 com.selenium.commons.Configuration;
public class Home {
public WebDriver driver = Configuration.driver;
@FindBy(id="usrId")
private WebElement user;
@FindBy(id="pswd")
private WebElement pswd;
@FindBy(id="tranId'")
private WebElement tranId;
@FindBy(id="logOn")
private WebElement logOn;
public Home()
{
PageFactory.initElements(Configuration.driver, this);
}
public void logon(String Username,String Password,String trns)
{
Configuration.driver.get(Configuration.URL);
Configuration.driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS);
try{
Thread.sleep(10000);
}
catch(Exception e)
{
}
Configuration.driver.switchTo().frame(Configuration.driver.findElement(By.xpath("//iframe[@id='lightbox_iframe_cookieBanner']")));
Configuration.driver.findElement(By.xpath("//a[text()='Continue']")).click();
driver.manage().window().maximize();
System.out.println(driver.getTitle());
driver.findElement(By.id("usrId")).sendKeys("Babita Sethi");
}
`
謝謝!這麼多...它工作 –
在stackoverflow,而不是說謝謝,我們upvote /接受。 –