「ウェルカムユーザー」テキストとユーザー名を比較してログインを確認しようとしています。 comapriosnは一致しません。 elem.getText()
のxpathテキストを出力すると、選択したテキストを含む追加のテキストが表示されます。xpath経由でログインを確認できません
適切なxpathを書き込む方法や、ログインを確認するためのコードを書く方法に関する提案は誰でも提供できますか?
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
public class verify_loign
{
public static void main(String []args)
{
WebDriver driver;
ProfilesIni profile = new ProfilesIni();
FirefoxProfile fire_profile = profile.getProfile("sele_prac");
driver=new FirefoxDriver(fire_profile);
driver.get("https://phptravels.org/clientarea.php");
driver.findElement(By.id("inputEmail")).sendKeys("[email protected]");
driver.findElement(By.id("inputPassword")).sendKeys("123456");
driver.findElement(By.id("login")).submit();
WebElement verify_login_ele = driver.findElement(By.xpath("//div[@class='header-lined' and contains(h1,'Welcome Back, rakesh')]"));
// String str = "Welcome Back, rakesh";
// if(verify_login_ele.equals(str))
// {
// System.out.println("Your logged in succesfully");
// }
// else
// {
// System.out.println("Something went wrong with valid credential");
// }
System.out.println(verify_login_ele.getText());
driver.findElement(By.id("Secondary_Navbar-Account")).click();
driver.findElement(By.id("Secondary_Navbar-Account-Logout")).click();
driver.close();
driver.quit();
}
}
誰もがphptravels.org ...上のアカウントを持っているあなたが言及した歓迎の 'HTML'を共有することができますメッセージ? – Andersson