TestNG by default disables loading DTD from unsecure Urls

后端 未结 14 882
[愿得一人]
[愿得一人] 2021-01-02 00:10

I\'m using testng maven and selenium to run my tests, currently I have the following testng.xml file

Looks like the problem is with the &listeners and &class

相关标签:
14条回答
  • 2021-01-02 00:40

    To solve this problem in Eclipse follow following steps:

    1. Go to windows -> Preferences->TestNG->Run/Debug
    2. In JVM_args add the following -Dtestng.dtd.http=true
    3. Click on Apply and close button.
    4. Right-click on your project select Maven -> Update project
    5. Now go to your pom.xml and click on Run as ->Maven Test

    Now below problem "TestNG by default disables loading DTD from unsecure Urls" will not be there.

    0 讨论(0)
  • 2021-01-02 00:42
    1. If you run your project only from the eclipse/other IDE's update your TestNG preferences and add statement -Dtestng.dtd.http=true in JVM_args.
    2. If you are looking for a general fix where you run maven from CLI as well then update all your TestNG.xml files

    FROM

     <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
    

    TO:

    <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
    

    I personally prefer updating the DOCTYPE.

    0 讨论(0)
  • 2021-01-02 00:43

    Just change all yours

    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"

    on https:

    <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"

    0 讨论(0)
  • 2021-01-02 00:46
    1. Right Click on the class, select Run--> Run configuration
    2. By default one testNg class will be generated with same class name under testng option
    3. Select that class and go to Arguments tab
    4. In the VM arguments provide -Dtestng.dtd.http=true

    Thats it.

    0 讨论(0)
  • 2021-01-02 00:47

    Please follow all the steps as below. Works perfectly after configuring JVM arguments in Eclipse.

    Problem Statement:

    TestNG by default disables loading DTD from unsecure Urls If you need to explicitly load the DTD from a http url, please do so by using the JVM argument [-Dtestng.dtd.http=true]

    Often we need to use certain VM arguments on the JVM that launches the Rule Project.

    To do so, the following 2 steps are needed: • Define a new installed JRE with default JVM arguments: -- Go to the Eclipse Window > preferences > Java > Installed JREs". -- Select the Default JRE and Click on Duplicate. -- Change the JRE name as per your choice, for example myJRE and Enter the Default VM arguments as “-Dtestng.dtd.http=true” enter image description here

    -- Click Finish. --- Uncheck the default JRE and check the new JRE added with VM arguments. --- Click Apply, Apply and Close.

    • Configure the Rule Project launch configuration to use the new installed JRE: -- Go to the Run > Run Configurations --- Run Configuration Dialog is in view.

    enter image description here

    --- Enter the Name of your choice, for example: RunConfigWithJVMArgs. --- Test tab:  Project name by default displayed.  Select the “Suite” option and browse for your testng.xml file present in your project folder. For example: src/main/resources/testng.xml enter image description here

    --- Arguments tab:  Enter ““-Dtestng.dtd.http=true” in the VM arguments text field. --- JRE tab:  Select “Alternate JRE : “ as the newly added JRE with JVM arguments. --- No other changes required. --- Click Apply and then Run.

    If the suite starts and runs successfully in Eclipse, then it will work when you run the packaged JAR file as well.

    Note: Perform mvn clean and mvn package –Dmaven.test.skip=true after changing the above configurations in Eclipse.

    Once the JAR is ready, it will have the new JRE configured with JVM arguments and it will fix the problem statement.

    0 讨论(0)
  • 2021-01-02 00:49

    In the TestNG file change the value (http) inside the <!DOCTYPE> parameter into https as highlighted in the below image. That is it.

    0 讨论(0)
提交回复
热议问题