0
嗨我想爲Chrome自動化AdvancedRestClient擴展來測試web服務。 我能夠啓動擴展和發送請求。但我無法得到任何迴應。Automationg AdvancedRestClient擴展爲鉻
public class WebServices {
public static void main(String[] args) {
//Start the driver
System.setProperty("webdriver.chrome.driver","$PATH_TO_DRIVER");
ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=C:/Users/$username/AppData/Local/Google/Chrome/User Data/Default/Extensions/hgmloofddffdnphfgcellkdfbfbjeloo/3.1.7_0");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
//Start the extension
driver.get("chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/RestClient.html");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//Get the authentication field and set authentication
WebElement authField = driver.findElement(By.xpath("//*[@id='appContainer']/div/div/div/div[4]/div[2]/section[1]/textarea"));
authField.sendKeys("$SET_AUTORIZATION")
//Get the reqestURL field and enter request
WebElement requestField = driver.findElement(By.xpath("//*[@id='appContainer']/div/div/div/div[2]/input"));
requestField.clear();
requestField.sendKeys("$REQUEST");
authField.click();
//Click on send button
WebElement sendButton = driver.findElement(By.xpath("//*[@id='appContainer']/div/div/div/div[7]/div/button[2]"));
sendButton.click();
}
}
上面的步驟工作正常,當我手動做。但腳本不會產生任何迴應。 請幫忙。
你能分享任何文檔或與上述方法相關嗎?另外我想知道爲什麼沒有響應產生。手冊正在運行,腳本失敗 – Sighil
試試這個庫https://github.com/rest-driver/rest-driver –