2017-09-11 4 views
-1

サイトに新しく、依然として質問をしています。 [OK]を私のAppiumコードで使用する良いIFステートメントは何ですか

UPDATE私のコードにいくつかの変更を行った後、私は今、私のコードでは、このIF文を持っているので、私の問題は、IF文が真であるならば、それはその特定のページに進んだがしかし、クリックしないだろうボタンの上に。私のコードは正しいですか、私はいくつかの部分が欠けていますか?

driver.findElement(By.id(redButton)).click(); 

    driver.findElement(By.id(good)).click(); 

    driver.findElement(By.id(locator)).click(); 

    //IF statement with variable named "viewdets" 
    //If "View Details & Pay" button pops up click 
    if (!driver.findElements(By.id(viewdets)).isEmpty()) { 
     driver.findElement(By.id(viewdets)).click(); 
     //App Closes and Doesn't Click Pay Button 
     driver.findElement(By.id(pay)).click(); 
     driver.findElement(By.id(conpay)).click(); 
    //If not then continue to stall and check in 
    } else { 
     Thread.sleep(7000); 
     driver.findElement(By.id(stall)).click(); 
     driver.findElement(By.id(two)).click(); 
     driver.findElement(By.id(three)).click(); 
     driver.findElement(By.id(next)).click(); 

     wait = new WebDriverWait(driver, 15); 
     wait.until(ExpectedConditions.elementToBeClickable(By.id(pay))); 

     driver.findElement(By.id(pay)).click(); 
     driver.findElement(By.id(conpay)).click(); 
     driver.findElement(By.id(receipt)).click(); 
+0

何が質問ですか? – AntonH

+0

@AntonHが更新されました。まだこのサイトで質問をしています。 –

+0

https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/を読んでみてください。はい、長くても非常に良いコンテンツです。 – AntonH

答えて

0

おそらく、次の予想される要素が画面に存在するかどうかを確認できます。 成功この画面か、他ではないにあなたを導くでしょうだったら、前の2回のクリック(「詳細を見る&ペイ」ボタン)を想定すると

org.junit.Assert.assertFalse(driver.findElements(By.id(good)).isEmpty()); 

あなたがナビゲートしたページにidの要素があることを確認します。そして、それ以上のアクションを実行してください:

driver.findElement(By.id(good)).click(); 
+0

あなたは私の新しいアップデートを見てみることができますか?@nullpointer –

関連する問題