首页 > 解决方案 > 使用 Tosca 执行 Selenium 脚本

问题描述

我正在尝试在 Tosca 中运行现有的 Selenium 脚本。但似乎有一个问题,现有的文章都没有真正帮助我。

我使用了标准的 tbox 模块“Start Selenium Server”和“Run Selenium Scripts”。在这些模块中,我将路径更改为使用 maven 创建的 .jar 文件。我已经用 junit 4 编写了测试用例,并使用 chrome webdriver 来执行它们。当我在 IntelliJ 中执行它们时,它们工作得非常好,但是一旦我尝试导入它们,Tosca 就无法执行。代码如下所示:

public class F {

private WebDriver driver;
private JavascriptExecutor js;
private WebDriverWait wait;


@Before
public void init(){
    System.setProperty("webdriver.chrome.driver", "P:/Documents/seflx/chromedriver.exe");
    driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    js = (JavascriptExecutor) driver;
    wait = new WebDriverWait(driver, 30);
    driver.manage().window().maximize();
    driver.get("url");
}

@Test
public void searchSubmission() {
    driver.switchTo().defaultContent();
    driver.switchTo().frame("workflow_frame_1");
    WebElement initScreen = driver.findElement(By.className("loading-screen"));
    WebElement loadingScreen = driver.findElement(By.xpath("/html"));
}

正如您在代码中看到的,我没有主类,这是问题所在吗?因为我在 Tosca 的纪录片中读到支持 junit。

我期望的是在 tosca 中执行 selenium jar 文件。我得到的当前结果是这样的:

 Selenium Server started successfully
 Run Selenium Scripts: startIndex cannot be larger than length of string.
 Parameter name: startIndex
System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Tricentis.Automation.SpecialExecutionTasks.SeleniumExecution.ExecuteSeleniumTestsSpecialExecutionTask.AnalyzeJunitTestResult(String resultMessage, String outputHtml, String projectPathToLog)
   at Tricentis.Automation.SpecialExecutionTasks.SeleniumExecution.ExecuteSeleniumTestsSpecialExecutionTask.Execute(ISpecialExecutionTaskTestAction testAction)
   at Tricentis.Automation.SpecialExecutionTasks.SeleniumExecution.ExecuteSeleniumTestsSpecialExecutionTask.ExecuteTask(ISpecialExecutionTaskTestAction testAction)
   at ᜈ.ᜀ()
   at ᜈ.ᜁ()
   at Tricentis.Automation.Execution.ItemExecutor`1.Execute()

tosca 输出截图

标签: javaseleniumtosca

解决方案


推荐阅读