0
私はセレニウムとTestNGにjavaを使って作業しています。私はポップアップを処理する方法についていくつかの問題があります。ここでは、一度に2つのプロセスがあります。ボタンをクリックすると成分がある場合はポップアップが開き、それ以外の場合はカートに直接追加されます。だから私は使用:selenium webdriverを使用して2つの異なる方法で1つの出力を取得するにはどうすればよいですか?
@Test
public void ingredient_Popup()
{
String ingre_Title="Choose product choices...";
String ingre_Title1=d.findElement(By.className("modal-dialog")).getText();
if(ingre_Title.contentEquals(ingre_Title1))
{
d.findElement(By.id("ingredient_quantity")).sendKeys("1");
d.findElement(By.linkText("SUBMIT")).click();
}
else
{
d.findElement(By.xpath("/html/body/section[3]/div[2]/div/div/div/div/div/div[1]/div[3]/div/div/div[3]/div/div[1]/table/tbody/tr/td[2]/div/span[2]/button")).click();
}
And also i used (II)
@Test
public void ingredient_Popup()WebElement element;
try
{
element = d.findElement(By.className("modal-dialog")); >}
catch(NoSuchElementException n)
{
element = null;
}
{
if(element !=null)
{
d.findElement(By.id("ingredient_quantity")).sendKeys("1");
d.findElement(By.linkText("SUBMIT")).click();
}
else
{
d.findElement(By.className("btn btn-default btn-number")).click();
}
}
And i used, isenabled, Contains, equals, isdisplayed, isElementPresent
if(ingre_Title.isEnabled())
{
d.findElement(By.id("ingredient_quantity")).sendKeys("1");
d.findElement(By.linkText("SUBMIT")).click();
}
else
{
d.findElement(By.xpath("/html/body/section[3]/div[2]/div/div/div/div/div/div[1]/div[3]/div/div/div[3]/div/div[1]/table/tbody/tr/td[2]/div/span[2]/button")).click();
}
And i tried a lot, Nothing is working. i'm getting NoSuchElementException
error.
だから、親切に、誰もがコードを作成し、私と一緒にそれを共有します。
@Stepi Kzyalがこれはあなたのために働いていますか? –