当我尝试运行代码时,会出现错误消息

时间:2017-06-22 07:29:05

标签: java selenium

当我尝试在提及代码下面运行时,会出现错误消息。在我的代码中,我正在尝试执行注销功能。对于这个注销功能,我准备了一个excel,其中logout xpath正确存储。但是当我尝试执行此代码时,会出现错误消息。错误消息是元素在点(1155,20)处不可点击。其他元素将收到点击

package com.rmspl.multiplemethod;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

public class MethodSet {
static WebElement element;

public void login (String username,String password,String nr,WebDriver fd) {

     fd.get("http://117.247.65.9/vms_test");
     fd.manage().window().maximize();

    WebElement E1 = fd.findElement(By.name("j_username"));
    E1.sendKeys(username);

    WebElement E2 = fd.findElement(By.name("j_password"));
    E2.sendKeys(password);

    WebElement E3 = fd.findElement(By.name("log"));
    E3.click();

    }

        public void clickLink(String xPath,String nr,String nr1,WebDriver fd){
        element = fd.findElement(By.xpath(xPath));
        element.click();
        }
        public void Select(String xPath,String val,String nr1,WebDriver fd){
        Select sel = new Select(fd.findElement(By.xpath(xPath)));
        sel.selectByValue(val);
  }
}

package com.rmspl.multiplemethod;

import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;


public class TestDriver {

    static WebElement element;
    public static void main(String[] args) throws BiffException, IOException, NoSuchMethodException, SecurityException, 
    IllegalAccessException,IllegalArgumentException, InvocationTargetException {

    MethodSet mt = new MethodSet();

    System.setProperty("webdriver.chrome.driver","C:\\Users\\Arijit Mohanty\\Desktop\\chromedriver.exe");
    WebDriver fd = new ChromeDriver();

    FileInputStream fis = new FileInputStream("C:\\Users\\Arijit Mohanty\\Desktop\\Bangla\\HybridDatasheet.xls");
    Workbook WB = Workbook.getWorkbook(fis);
    Sheet Sh = WB.getSheet("Sheet2");

    int rows = Sh.getRows();
    int cols = Sh.getColumns();

    for (int i = 1; i<rows; i++)
        {
        String methodname = Sh.getCell(0, i).getContents();
        String data1 = Sh.getCell(1, i).getContents();
        String data2 = Sh.getCell(2, i).getContents();
        String data3 = Sh.getCell(3, i).getContents();

        Method m1 =  mt.getClass().getMethod(methodname, String.class,String.class,String.class, WebDriver.class);
        m1.invoke(mt,data1,data2,data3,fd);
        }


    }

}

1 个答案:

答案 0 :(得分:0)

您需要等待loading_bg直到离开屏幕。请更新方法clickLink,如下所示。请尝试告诉我们。

<ul class="list-unstyled alerts-list contracts-alert-list">
  <li>
      <div class="alert-list-left">
          <div class="alert-time  contracts-alert">
              <p>10:31 AM</p>
          </div>
          <p>
              <span class="alert-title">Alert 1</span>

          </p>
      </div>
      <a href=""><i class="fa fa-times" aria-hidden="true"></i></a>
  </li>
  <li>
      <div class="alert-list-left">
          <div class="alert-time  contracts-alert">
              <p>10:31 AM</p>
          </div>
          <p>
              <span class="alert-title">Alert 1</span>

          </p>
      </div>
      <a href=""><i class="fa fa-times" aria-hidden="true"></i></a>
  </li>
  <li>
      <div class="alert-list-left">
          <div class="alert-time  contracts-alert">
              <p>10:31 AM</p>
          </div>
          <p>
              <span class="alert-title">Alert 1</span>

          </p>
      </div>
      <a href=""><i class="fa fa-times" aria-hidden="true"></i></a>
  </li>
  <li class="note">
      <form action="some-action" class="add-note-form">
          <input type="text" class="form-control" placeholder="">
          <button type="submit" class="btn form-submit-btn submit-new-note-2">Add Note</button>
      </form>
  </li>
</ul>
<button type="button" class="btn add-alert-btn add-note"><i class="fa fa-plus" aria-hidden="true"></i> Add Note Here</button>


<ul class="list-unstyled alerts-list contracts-alert-list">
  <li>
      <div class="alert-list-left">
          <div class="alert-time  contracts-alert">
              <p>10:31 AM</p>
          </div>
          <p>
              <span class="alert-title">Alert 1</span>

          </p>
      </div>
      <a href=""><i class="fa fa-times" aria-hidden="true"></i></a>
  </li>
  <li>
      <div class="alert-list-left">
          <div class="alert-time  contracts-alert">
              <p>10:31 AM</p>
          </div>
          <p>
              <span class="alert-title">Alert 1</span>

          </p>
      </div>
      <a href=""><i class="fa fa-times" aria-hidden="true"></i></a>
  </li>
  <li>
      <div class="alert-list-left">
          <div class="alert-time  contracts-alert">
              <p>10:31 AM</p>
          </div>
          <p>
              <span class="alert-title">Alert 1</span>

          </p>
      </div>
      <a href=""><i class="fa fa-times" aria-hidden="true"></i></a>
  </li>
  <li class="note">
      <form action="some-action" class="add-note-form">
          <input type="text" class="form-control" placeholder="">
          <button type="submit" class="btn form-submit-btn submit-new-note-2">Add Note</button>
      </form>
  </li>
</ul>
<button type="button" class="btn add-alert-btn add-note"><i class="fa fa-plus" aria-hidden="true"></i> Add Note Here</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

}