Selenium 运行使用testNG的程序时,首先在字段中添加无效数据,然后清除,然后是登录的有效凭据

Selenium 运行使用testNG的程序时,首先在字段中添加无效数据,然后清除,然后是登录的有效凭据,selenium,onclick,testng,Selenium,Onclick,Testng,执行脚本时出现错误,下面我提到了我运行的脚本,请检查并告诉我为什么会遇到此错误 java.io.IOException: Access is denied at java.base/java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.base/java.io.File.createNewFile(Unknown Source) at org.testng.intern

执行脚本时出现错误,下面我提到了我运行的脚本,请检查并告诉我为什么会遇到此错误

java.io.IOException: Access is denied
        at java.base/java.io.WinNTFileSystem.createFileExclusively(Native Method)       at java.base/java.io.File.createNewFile(Unknown Source)
        at org.testng.internal.Utils.writeFile(Utils.java:173)
        at org.testng.internal.Utils.writeFile(Utils.java:149)          atorg.testng.reporters.TestHTMLReporter.generateLog(TestHTMLReporter.java:320)          atorg.testng.reporters.TestHTMLReporter.onFinish(TestHTMLReporter.java:40)
        at org.testng.TestRunner.fireEvent(TestRunner.java:1250)
        at org.testng.TestRunner.afterRun(TestRunner.java:1041)
        at org.testng.TestRunner.run(TestRunner.java:628)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
        at org.testng.SuiteRunner.run(SuiteRunner.java:261)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
代码,我运行它来执行测试,上面是错误,执行上面和下面的脚本时出现错误我提到了我运行的脚本,请检查并让我知道为什么会遇到此错误

 package TestNG;

    import java.io.IOException;
    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.By;
    import org.openqa.selenium.Keys;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.interactions.Actions;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.Test;

    public class testng {

         WebDriver driver;          

            // Method 1: Open Brower say Firefox            
            @Test (priority = 1)        
            public void openBrowser() {             
                driver = new FirefoxDriver();               

           // public void launch() {                
                driver.get("URL");                      
            }       


        @Test (priority = 2)

         public void one() throws InterruptedException {



              driver.findElement(By.xpath(".//*[@id='user_login']")).sendKeys("Invalid Email");



             driver.findElement(By.xpath(".//*[@id='user_login_password']")).sendKeys("Invalid Password");



             driver.findElement(By.xpath(".//*[@id='user_login_btn']")).click();



              System.out.println("Error has occur wrong credentials");
         }

         @Test (priority = 3)

          public void two() {

                  driver.findElement(By.xpath(".//*[@id='user_login']")).clear();
                  driver.findElement(By.xpath(".//*[@id='user_login_password']")).clear();
                  driver.findElement(By.xpath(".//*[@id='user_login']")).sendKeys("Valid");
                  driver.findElement(By.xpath(".//*[@id='user_login_password']")).sendKeys("Valid");
                  driver.findElement(By.xpath(".//*[@id='user_login_btn']")).click();

你还没有设定壁虎河的路径。 请在方法openBrowser()中设置驱动程序路径

可使用以下代码设置驱动程序路径:

 System.setProperty("webdriver.gecko.driver","path of geckodriver");
 driver = new FirefoxDriver();               

请共享失败的代码块,在创建文件的位置添加,请选中尝试以管理员身份运行脚本