【问题标题】:How to automate SOAP UI in selenium Web driver如何在 selenium Web 驱动程序中自动化 SOAP UI
【发布时间】:2015-08-24 06:42:57
【问题描述】:

我们有一个应用程序,其中有一个客户模块。 在这里它将显示在字段下方 顾客姓名 地址1 地址2 城市 状态

要在网页中获取客户模块中的记录,我们需要在soap UI 中提供输入数据,一旦从soap UI 执行后,将创建一个新客户并显示在UI 网页中。 我们如何通过 selenium Web 驱动程序自动化这个过程。

【问题讨论】:

  • 将soapUI 与您的硒测试套件集成在IMO 中是不值得的。我建议在您的 selenium 套件中创建一个类来执行创建用户的服务调用,并将该步骤作为数据设置的一部分......即使您还不知道如何做到这一点,也将花费更少的时间并努力学习在硒框架中进行服务调用,而不是尝试做一些猴子补丁来在硒测试中调用soapui......
  • 您可以创建一些在测试运行之前执行的设置脚本。肥皂客户端示例可以在这里找到stackoverflow.com/q/15948927/2504101
  • 如果你想使用soapui api然后看看stackoverflow.com/questions/16773173/… - @priti的回答
  • 如果您认为它可以解决您的问题,请accept 回答。它将在整个社区中识别正确的解决方案。这可以通过单击答案旁边的绿色复选标记来完成。请参阅此image 以供参考。干杯。

标签: java selenium selenium-webdriver


【解决方案1】:

因此,让 Selenium 和 SoapUI 合作的最明显,也许也是最简单的方法是:

  1. 安装 SoapUI。
  2. 下载 Selenium(您需要 selenium-server-standalone-2.*.jar) 并将其放入您的 SoapUI 安装中(放入 %SOAPUI_HOME%\bin\ext)。
  3. 启动 SoapUI;开始一个新项目;创建一个新的测试用例;添加一个 新的 Groovy 步骤;将sample code 复制粘贴到步骤中。我制造了一个 少量修改:删除package 行,删除class Selenium2Example 和void main 行以及关闭 括号,并将System.out.println 更改为log.info。我的决赛 (完整)测试代码如下。
  4. 单击播放。你应该会看到 Firefox 启动,导航到 谷歌,然后您应该会看到 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 的复制粘贴。

【讨论】:

  • 大家帮我在 Eclipse Juno Service Release 1 中设置 Groovy。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-17
  • 2020-10-05
  • 2022-01-28
  • 1970-01-01
  • 2017-08-15
相关资源
最近更新 更多