缺少关闭引号错误 运行 jmeter 脚本
Getting Missing close quote error running the jmeter scripts
下面的脚本工作正常,突然出现问题,无法确定这里的问题所在。如果我用其他任何东西替换文件路径,那么它就可以工作。我对该文件夹具有写入权限,并且能够多次 运行 测试以将文件保存到该位置。脚本一开始测试就显示这个错误
var selenium = JavaImporter(org.openqa.selenium)
var time = JavaImporter(java.util.concurrent.TimeUnit)
WDS.browser.manage().timeouts().implicitlyWait(30, time.TimeUnit.SECONDS)
var support_ui=JavaImporter(org.openqa.selenium.support.ui)
var home = java.lang.System.getProperty('user.dir')
var io = JavaImporter(java.io)
WDS.sampleResult.sampleStart()
WDS.log.info("Load the application");
WDS.sampleResult.subSampleStart('Load the application')
WDS.browser.get('https://ea-webapp-stg-test.com/getting-started')
WDS.log.info("Enter the Credentials and click on Login");
WDS.sampleResult.subSampleStart('Enter the Credentials and click on Login')
WDS.browser.findElement(selenium.By.id("username")).sendKeys("test-user");
WDS.browser.findElement(selenium.By.id("password")).sendKeys("Testpass");
WDS.browser.findElement(selenium.By.id("ravenTermsAgree")).click();
WDS.browser.findElement(selenium.By.id("kc-login")).click();
takeScreenshot('Screenshot_Logging')
function takeScreenshot(fileName){
WDS.log.info("Taking screenshots for: "+fileName);
screenshot = WDS.browser.getScreenshotAs(selenium.OutputType.FILE)
screenshot.renameTo(new java.io.File(home + '\Test data set\screenshots\'+fileName+'.png'))
}
WDS.sampleResult.sampleEnd()
错误显示为
2022-03-24 17:39:34,790 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2022-03-24 17:39:52,507 INFO c.g.j.p.w.c.WebDriverConfig: Created browser object: ChromeDriver: chrome on WINDOWS (null)
2022-03-24 17:39:52,533 ERROR c.g.j.p.w.s.WebDriverSampler: <eval>:182:92 Missing close quote
screenshot.renameTo(new java.io.File(home + '\Test data set\screenshots\'+fileName+'.png'))
^ in <eval> at line number 182 at column number 92
2022-03-24 17:39:52,534 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
2022-03-24 17:39:52,534 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2022-03-24 17:39:53,136 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2022-03-24 17:39:53,137 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
看起来 \
字符被视为 escape meta character in string, I would recommend replacing it with system independent path separator
var selenium = JavaImporter(org.openqa.selenium)
var time = JavaImporter(java.util.concurrent.TimeUnit)
WDS.browser.manage().timeouts().implicitlyWait(30, time.TimeUnit.SECONDS)
var support_ui = JavaImporter(org.openqa.selenium.support.ui)
var home = java.lang.System.getProperty('user.dir')
var io = JavaImporter(java.io)
var slash = java.io.File.separator
WDS.sampleResult.sampleStart()
WDS.log.info("Load the application");
WDS.sampleResult.subSampleStart('Load the application')
WDS.browser.get('https://ea-webapp-stg-test.com/getting-started')
WDS.log.info("Enter the Credentials and click on Login");
WDS.sampleResult.subSampleStart('Enter the Credentials and click on Login')
WDS.browser.findElement(selenium.By.id("username")).sendKeys("test-user");
WDS.browser.findElement(selenium.By.id("password")).sendKeys("Testpass");
WDS.browser.findElement(selenium.By.id("ravenTermsAgree")).click();
WDS.browser.findElement(selenium.By.id("kc-login")).click();
takeScreenshot('Screenshot_Logging')
function takeScreenshot(fileName) {
WDS.log.info("Taking screenshots for: " + fileName);
screenshot = WDS.browser.getScreenshotAs(selenium.OutputType.FILE)
screenshot.renameTo(new java.io.File(home + slash + 'Test data set' + slash + 'screenshots' + slash + fileName + '.png'))
}
WDS.sampleResult.sampleEnd()
更多信息:
下面的脚本工作正常,突然出现问题,无法确定这里的问题所在。如果我用其他任何东西替换文件路径,那么它就可以工作。我对该文件夹具有写入权限,并且能够多次 运行 测试以将文件保存到该位置。脚本一开始测试就显示这个错误
var selenium = JavaImporter(org.openqa.selenium)
var time = JavaImporter(java.util.concurrent.TimeUnit)
WDS.browser.manage().timeouts().implicitlyWait(30, time.TimeUnit.SECONDS)
var support_ui=JavaImporter(org.openqa.selenium.support.ui)
var home = java.lang.System.getProperty('user.dir')
var io = JavaImporter(java.io)
WDS.sampleResult.sampleStart()
WDS.log.info("Load the application");
WDS.sampleResult.subSampleStart('Load the application')
WDS.browser.get('https://ea-webapp-stg-test.com/getting-started')
WDS.log.info("Enter the Credentials and click on Login");
WDS.sampleResult.subSampleStart('Enter the Credentials and click on Login')
WDS.browser.findElement(selenium.By.id("username")).sendKeys("test-user");
WDS.browser.findElement(selenium.By.id("password")).sendKeys("Testpass");
WDS.browser.findElement(selenium.By.id("ravenTermsAgree")).click();
WDS.browser.findElement(selenium.By.id("kc-login")).click();
takeScreenshot('Screenshot_Logging')
function takeScreenshot(fileName){
WDS.log.info("Taking screenshots for: "+fileName);
screenshot = WDS.browser.getScreenshotAs(selenium.OutputType.FILE)
screenshot.renameTo(new java.io.File(home + '\Test data set\screenshots\'+fileName+'.png'))
}
WDS.sampleResult.sampleEnd()
错误显示为
2022-03-24 17:39:34,790 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2022-03-24 17:39:52,507 INFO c.g.j.p.w.c.WebDriverConfig: Created browser object: ChromeDriver: chrome on WINDOWS (null)
2022-03-24 17:39:52,533 ERROR c.g.j.p.w.s.WebDriverSampler: <eval>:182:92 Missing close quote
screenshot.renameTo(new java.io.File(home + '\Test data set\screenshots\'+fileName+'.png'))
^ in <eval> at line number 182 at column number 92
2022-03-24 17:39:52,534 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
2022-03-24 17:39:52,534 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2022-03-24 17:39:53,136 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2022-03-24 17:39:53,137 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
看起来 \
字符被视为 escape meta character in string, I would recommend replacing it with system independent path separator
var selenium = JavaImporter(org.openqa.selenium)
var time = JavaImporter(java.util.concurrent.TimeUnit)
WDS.browser.manage().timeouts().implicitlyWait(30, time.TimeUnit.SECONDS)
var support_ui = JavaImporter(org.openqa.selenium.support.ui)
var home = java.lang.System.getProperty('user.dir')
var io = JavaImporter(java.io)
var slash = java.io.File.separator
WDS.sampleResult.sampleStart()
WDS.log.info("Load the application");
WDS.sampleResult.subSampleStart('Load the application')
WDS.browser.get('https://ea-webapp-stg-test.com/getting-started')
WDS.log.info("Enter the Credentials and click on Login");
WDS.sampleResult.subSampleStart('Enter the Credentials and click on Login')
WDS.browser.findElement(selenium.By.id("username")).sendKeys("test-user");
WDS.browser.findElement(selenium.By.id("password")).sendKeys("Testpass");
WDS.browser.findElement(selenium.By.id("ravenTermsAgree")).click();
WDS.browser.findElement(selenium.By.id("kc-login")).click();
takeScreenshot('Screenshot_Logging')
function takeScreenshot(fileName) {
WDS.log.info("Taking screenshots for: " + fileName);
screenshot = WDS.browser.getScreenshotAs(selenium.OutputType.FILE)
screenshot.renameTo(new java.io.File(home + slash + 'Test data set' + slash + 'screenshots' + slash + fileName + '.png'))
}
WDS.sampleResult.sampleEnd()
更多信息: