我有错误:预期[object Undefined] undefined为字符串 我不知道如何解决它。 我不知道如何修复它,我不知道在哪里搜索潜在的错误。
Firefox已启动但未执行任何预期访问该网站的内容。
我的变量paramTest2,paramTest3,paramTest4 ...都是空的,我不明白为什么......只有paramTest1包含一些内容,这就是网址。
以下是完整的跟踪:
[TestNG] Running:
C:\Temp\testng-eclipse--806319973\testng-customsuite.xml
###################################################
##### TEST : Connexion
##### DESCRIPTION : Test sur la connexion
###################################################
1491402504078 geckodriver INFO Listening on 127.0.0.1:13254
1491402504745 mozprofile::profile INFO Using profile path C:\Temp\rust_mozprofile.IGVKHcaTXwv0
1491402504751 geckodriver::marionette INFO Starting browser C:\Program Files\Nightly\firefox.exe with args []
1491402504759 geckodriver::marionette INFO Connecting to Marionette on localhost:60098
1491402505513 Marionette WARN Deprecated preference marionette.defaultPrefs.enabled detected, please use marionette.enabled
[GPU 7556] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-cen-w64-ntly-000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 11252] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-cen-w64-ntly- 000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 11252] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-cen-w64-ntly-000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
1491402507490 Marionette INFO Listening on port 60098
1491402507875 Marionette WARN TLS certificate errors will be ignored for this session
avr. 05, 2017 4:28:27 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFOS: Detected dialect: W3C
Connexion au site : https://wd3-impl.workday.com/ag_preview/login.htmld?redirect=n
Connexion à l'espace client
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\Default suite\Default test.xml
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\Default suite\Default test0.xml
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\Default suite exists: true
FAILED: testCas("Connexion", "testcases\testcase1.csv", "Test sur la connexion")
org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
System info: host: 'TOLX300092143', ip: '44.10.108.53', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Temp\rust_mozprofile.IGVKHcaTXwv0, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=55.0a1, platformVersion=6.1, moz:processID=7624, browserName=firefox, platformName=windows_nt}]
Session ID: 44ae5d76-506f-4cd3-95c6-b11b71455bfd
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:133)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:99)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:43)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:51)
at com.sun.proxy.$Proxy6.sendKeys(Unknown Source)
at selenium.FindElements.connexionWD(FindElements.java:27)
at selenium.SeleniumTest.testEtape(SeleniumTest.java:105)
at selenium.SeleniumTest.testCas(SeleniumTest.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1137)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:753)
at org.testng.TestRunner.run(TestRunner.java:607)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:363)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:321)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.jq.Main@13fee20c: 75 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@4cb2c100: 15 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@5d624da6: 8 ms
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\toc.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\Default test.properties
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\index.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\main.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\groups.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\classes.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\reporter-output.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\methods-not-run.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1 \Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite\testng.xml.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\Default suite exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old\index.html
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\old exists: true
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@5f2050f6: 44 ms
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\junitreports\TEST-selenium.SeleniumTest.xml
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\junitreports exists: true
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@77b52d12: 10 ms
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\testng-failed.xml
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output exists: true
[Utils] Attempting to create C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\Default suite\testng-failed.xml
[Utils] Directory C:\Users\ng647f1\Desktop\Worspaces_Automation\WD_Automation\WD_Automation_EXPORT\WD_Automation\test-output\Default suite exists: true
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 15 ms
这是我的脚本findElements:
package selenium;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
public class FindElements {
final WebDriver driver;
@FindBy(how = How.XPATH, using = "//input[@aria-label=\"Nom d'utilisateur\"]")
public WebElement PSEUDO;
@FindBy(how = How.XPATH, using = "//input[@aria-label='Mot de passe']")
public WebElement MDP;
@FindBy(how = How.CLASS_NAME, using = "GDQYR4DOVK")
public WebElement CONNECT;
public FindElements(WebDriver driver){
this.driver = driver;
}
public void connexionWD(String EmailConnect, String MdpConnect){
PSEUDO.sendKeys(EmailConnect);
MDP.sendKeys(MdpConnect);
CONNECT.click();
}
}
这是我的脚本SeleniumTest:
package selenium;
import java.io.IOException;
import org.testng.annotations.Test;
import org.testng.annotations.DataProvider;
import java.io.FileReader;
import java.util.List;
import com.opencsv.*;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SeleniumTest {
private static WebDriver driver = null;
@DataProvider(name = "testPlan")
public Object[][] motCles() throws IOException {
//Lecture du plan de test avec Open CSV
CSVReader reader = new CSVReader(new FileReader("testplan.csv"), ';', '"', 1);
int i = 0;
List<String[]> allRows = reader.readAll();
Object testPlan[][]= new Object[allRows.size()][3];
for(String[] row : allRows){
testPlan[i][0] = row[0];
testPlan[i][1] = row[1];
testPlan[i][2] = row[2];
i++;
}
reader.close();
return testPlan;
}
@Test(dataProvider = "testPlan")
public void testCas(String nomTest, String lienTest, String descTest) throws Exception {
//Lecture du cas de test avec OpenCSV
CSVReader reader = new CSVReader(new FileReader(lienTest), ';', '"', 1);
//System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
//System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");
System.setProperty("webdriver.firefox.marionnette","C:\\Users\\ng647f1\\Desktop\\Worspaces_Automation\\WD_Automation\\WD_Automation_EXPORT\\WD_Automation\\geckodriver.exe");
int i = 0;
int j = 0;
System.out.println("###################################################");
System.out.println("##### TEST : " + nomTest);
System.out.println("##### DESCRIPTION : " + descTest);
System.out.println("###################################################");
List<String[]> allRows = reader.readAll();
String testDescription[][]= new String[50][21];
//Sélection du navigateur utilisé pour le test en cours. Ce navigateur est défini dans les cas de tests.
DesiredCapabilities capabilities;
capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
capabilities.setCapability("proxyType", "pac");
capabilities.setCapability("acceptInsecureCerts", true);
capabilities.setCapability("browser.private.browsing.autostart", true);
driver = new FirefoxDriver(capabilities);
//On agrandit la fenêtre de test pour éviter les problèmes d'invisibilité d'éléments avec ChromeDriver.
driver.manage().window().maximize();
//On définit le temps d'attente avant qu'un cas de test tombe en erreur quand un élément n'est pas trouvé.
driver.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS);
//On lit les paramètres du cas de test dans le fichier du plan de test
for(String[] row : allRows){
for(j = 0; j<=20; j++){
testDescription[i][j] = row[j];
}
if (testDescription[i][0] != null) {
//On lance le cas de test
testEtape(testDescription[i][0], testDescription[i][1], testDescription[i][2], testDescription[i][3], testDescription[i][4], testDescription[i][5], testDescription[i][6], testDescription[i][7], testDescription[i][8], testDescription[i][9], testDescription[i][10], testDescription[i][11], testDescription[i][12], testDescription[i][13], testDescription[i][14], testDescription[i][15], testDescription[i][16], testDescription[i][17], testDescription[i][18], testDescription[i][19], testDescription[i][20]);
}
i++;
}
driver.quit();
reader.close();
}
// Interprétation des mots-clés
public void testEtape(String motCle, String paramTest1, String paramTest2, String paramTest3, String paramTest4, String paramTest5, String paramTest6, String paramTest7, String paramTest8, String paramTest9, String paramTest10, String paramTest11, String paramTest12, String paramTest13, String paramTest14, String paramTest15, String paramTest16, String paramTest17, String paramTest18, String paramTest19, String paramTest20) throws Exception {
//On initialise les classes des pages avec PageFactory
FindElements FindElements1 = PageFactory.initElements(driver, FindElements.class);
//Pour chaque mot clé, des actions sont lancées. Certaines de ces actions sont des fonctions définies dans les classes des pages
switch(motCle.toUpperCase()){
case "ALLER":
System.out.println("Connexion au site : " + paramTest1);
driver.get(paramTest1);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
break;
case "CONNEXION":
System.out.println("Connexion à l'espace client");
FindElements1.connexionWD(paramTest1, paramTest2);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
break;
default :
System.out.println("||||| Mot clé non trouvé : " + motCle.toUpperCase());
}
}
}
我的脚本使用以下两个csv文件。
有testplan.csv:
Nom;Fichier;Description
Connexion;testcases\\testcase1.csv;Test sur la connexion
目前只包含一个测试用例testcase1.csv:
Mot clé;Paramètre 1;Paramètre 2;Paramètre 3;Paramètre 4;Paramètre 5;Paramètre 6;Paramètre 7;Paramètre 8;Paramètre 9;Paramètre 10;Paramètre 11;Paramètre 12;Paramètre 13;Paramètre 14;Paramètre 15;Paramètre 16;Paramètre 17;Paramètre 18;Paramètre 19;Paramètre 20
ALLER;https://wd3-impl.workday.com/ag_preview/login.htmld?redirect=n;;;;;;;;;;;;;;;;;;;
CONNEXION;thisIsMySecret@email;MySecretPassword;;;;;;;;;;;;;;;;;;
我希望你们中的一个能帮助我:)。
答案 0 :(得分:0)
如果您只想在testEtape
内调用方法testCas
而不是单独的测试,请从@Test
删除testEtape
。
答案 1 :(得分:0)
看起来selenium并没有跟上WebDriver ......
来自https://groups.google.com/forum/#!forum/selenium-users
从您的堆栈跟踪看起来Selenium发送了错误的JSON 身体到geckodriver。 geckodriver期待
{text: "string"}
而Selenium中的RemoteWebElement.java发送
{value: ["s", "t", "r", "i", "n", "g"]}
我会向Selenium提交一个错误。