我正在测试付款申请。程序是
直到第3步它才有效。但我在第4步使用HTTP请求。但用户名和密码不会在请求中传递,我不知道如何解决它。
如果有人帮我解决这个问题,对我来说很容易。
感谢。
答案 0 :(得分:0)
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()
答案 1 :(得分:0)
我有同样的问题,这里是我的灵魂:问题描述:我想在后端调用一个网站,它能够用JSON回复我。任务是测试JSON结构。我无法做到这一点,因为我总是为我的登录网站重定向。
解决方案:1。转到“显示服务查看器”并点击“服务端点”栏。输入http域和相应的用户名和密码。例如,我会调用"http://www.rocket.com/backend /homescreenJson"
,而不是我输入"endpont"="http://www.rocket.com
和我的用户名/传递,因为我将从浏览器登录。 2.在soapUI中找到文件/首选项,转到“HTTP设置”并选中以下框:“向传出请求添加身份验证设置”。
它对我有用。干杯,Karoly