package com.neoload.userpath; import static com.neotys.selenium.proxies.NLWebDriverFactory.addProxyCapabilitiesIfNecessary; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.security.GeneralSecurityException; import org.apache.olingo.odata2.api.exception.ODataException; import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.DesiredCapabilities; import com.neotys.rest.design.client.DesignAPIClient; import com.neotys.rest.design.client.DesignAPIClientFactory; import com.neotys.rest.error.NeotysAPIException; import com.neotys.selenium.proxies.NLWebDriver; import com.neotys.rest.design.builder.JSONDefinitionBuilder; import com.neotys.rest.design.builder.UserPathBuilder; import com.neotys.rest.design.model.element.ElementType; import com.neotys.selenium.proxies.NLWebDriverFactory; public class FirstCase { public static void main( String[] args ) throws Exception { final String url = "http://localhost:7400/Design/v1/Service.svc"; final DesignAPIClient client = DesignAPIClientFactory.newClient(url); // Create a UserPath with name "myUserpath" final UserPathBuilder builder = new UserPathBuilder("myUserpath"); // Put the cursor to the Actions container builder.moveToActions(); // Create a Transaction "myTransaction1", insert it in the Actions container and put the cursor inside it. builder.addChildAndMoveTo(ElementType.TRANSACTION.key(), new JSONDefinitionBuilder().name("myTransaction1").build()); // Create a Delay with 5 secondes duration and insert it in the Transaction "myTransaction1" builder.addChild(ElementType.DELAY.key(), new JSONDefinitionBuilder().put("Duration", "5000").build()); // Go up one level (out of the "myTransaction1" element builder.moveToParent(); // Create a Transaction "myTransaction2" and insert it after "myTransaction1" builder.addChild(ElementType.TRANSACTION.key(), new JSONDefinitionBuilder().name("myTransaction2").build()); // Build the full User Path structure and add it to the project builder.build(client); final FirefoxDriver webDriver = new FirefoxDriver(addProxyCapabilitiesIfNecessary(new DesiredCapabilities())); // projectPath used to open NeoLoad project, null to use the currently opened Project. final String projectPath = "PATH TO NEOLOAD PROJECT"; NLWebDriver driver = NLWebDriverFactory.newNLWebDriver(webDriver, "SeleniumUserPath", projectPath); driver.startTransaction("Login"); driver.get("My APPLICATION URL"); Thread.sleep(8000); driver.findElement(By.xpath("//input[@id='InputUsername']")).sendKeys("35577"); driver.findElement(By.xpath("//input[@id='InputPassword']")).sendKeys("demo"); driver.findElement(By.xpath("//button[@class='btn btn-primary']")).click(); Thread.sleep(10000); driver.startTransaction("SearchPAClick"); driver.findElement(By.xpath("//li[8]/a/span[2]/translate")).click(); driver.findElement(By.xpath("//li[3]/ul/li[3]/a/span/span[2]")).click(); Thread.sleep(10000); driver.findElement(By.xpath("//input[@name='GeneralCriteria.CaseReference']")).sendKeys("Test Data"); driver.findElement(By.xpath("(//button[@type='button'])[2]")).click(); driver.quit(); } }