2012-09-10 61 views
0

我正在測試支付應用程序。該程序是如何使用soapui登錄網站

  1. 第一次運行時支付Web服務調用..
  2. 發起支付響應將返回登錄URL。
  3. 從響應中取出網址並在瀏覽器中啓動它
  4. 輸入用戶名和密碼。
  5. 選擇登錄。它會轉到下一屏幕(屏幕說2)
  6. 在這裏,我需要通過CVC和選擇確認

直到它工作第3步。但我在第4步使用HTTP請求。但用戶名和密碼沒有通過請求,我不知道如何解決它。

如果有人能幫我解決這個問題,那對我來說很容易。

謝謝。

回答

0

進口org.openqa.selenium.By 進口org.openqa.selenium.WebDriver 進口org.openqa.selenium.WebElement 進口org.openqa.selenium.firefox.FirefoxDriver 進口org.openqa.selenium.support .ui.ExpectedCondition 進口org.openqa.selenium.support.ui.WebDriverWait

// Create a new instance of the Firefox driver 
    // Notice that the remainder of the code relies on the interface, 
    // not the implementation. 
    WebDriver driver = new FirefoxDriver() 

    // And now use this to visit Google 
    driver.get("http://www.google.com") 

    // Find the text input element by its name 
    WebElement element = driver.findElement(By.name("q")) 

    // Enter something to search for 
    element.sendKeys("Cheese!") 

    // Now submit the form. WebDriver will find the form for us from the element 
    element.submit() 

    // Check the title of the page 
    log.info("Page title is: " + driver.getTitle()) 

    // Google's search is rendered dynamically with JavaScript. 
    // Wait for the page to load, timeout after 10 seconds 
    (new WebDriverWait(driver, 10)).until(new ExpectedCondition() { 
     public Boolean apply(WebDriver d) { 
      return d.getTitle().toLowerCase().startsWith("cheese!") 
     } 
    }); 

    // Should see: "cheese! - Google Search" 
    log.info("Page title is: " + driver.getTitle()) 

    //Close the browser 
    driver.quit() 
+0

這是我試過的方式,它對我來說是... – ChanGan

0

我有同樣的問題,這裏是soultion對我來說:問題描述:我想在後臺調用一個網站,它能夠用JSON響應我。任務是測試JSON結構。我無法做到這一點,因爲我總是得到我的登錄網站的重定向。

解決方案:1.轉到「顯示服務查看器」並點擊「服務端點」欄。輸入http域名和相應的用戶名和密碼。例如,我會撥打"http://www.rocket.com/backend /homescreenJson",比輸入"endpont"="http://www.rocket.com和我的用戶名/密碼,因爲我會從瀏覽器登錄。 2.在soapUI中點擊File/Preferencies,進入「HTTP設置」,然後在下面的複選框中選擇「向傳出請求添加驗證設置」。

它爲我工作。乾杯,Karoly