2015-06-09 66 views
4

我們有一個應用程序,我們有一個客戶模塊。 這將顯示字段的下方 客戶名稱 地址1 地址2 市 國家如何在selenium Web驅動程序中自動化SOAP UI

要提取網頁中的客戶模塊的記錄,我們需要給肥皂UI輸入數據,一旦執行後從肥皂用戶界面,新用戶將創建並顯示在用戶界面網頁中。 我們如何通過硒Web驅動程序自動執行此過程。

+0

將soapUI與您的硒測試套件集成是不值得的海事組織。我建議在你的硒套件中創建一個類來執行創建用戶的服務調用,並將該步驟作爲數據設置的一部分... 即使您不知道如何執行該操作,更少的時間和精力來學習在硒框架內進行服務調用,而不是嘗試在硒測試中嘗試使用一些monkeypatch來調用soapui ... – Bodao

+0

您可以創建一些在測試運行之前正在執行的安裝腳本。肥皂客戶端的例子可以在這裏找到http://stackoverflow.com/q/15948927/2504101 – olyv

+0

如果你想使用soapui API然後看看http://stackoverflow.com/questions/16773173/how-to-創建一個soap-ui-project-and-run-requests-it-in-java - @priti的回答 – Kavan

回答

2

所以最明顯的,也許是最簡單的方法,讓硒和了SoapUI合作是:

  1. 安裝了SoapUI。
  2. 下載Selenium(您需要硒服務器獨立-2。*。jar) 並將其放入您的SoapUI安裝(到 %SOAPUI_HOME%\bin\ext)。
  3. 啓動SoapUI;開始一個新項目;創建一個新的測試用例;添加一個 新的Groovy步驟;將sample code複製粘貼到該步驟中。我做了一個 幾個修改:刪除package線,刪除class Selenium2Examplevoid main行以及關閉 括號,並將System.out.println更改爲log.info。我的最後 (完整)測試代碼如下。
  4. 點擊播放。您應該看到Firefox啓動,導航到 Google,之後您應該會看到SoapUI日誌條目。

示例代碼:

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.support.ui.ExpectedCondition 
import 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() 

這個答案是從my blog一個複製粘貼。

+0

任何人都可以幫助我在Eclipse Juno Service Release 1中設置Groovy。 – prem

+1

https://github.com/groovy/groovy-eclipse/wiki#how-to-install – SiKing

相關問題