當我試圖運行下面提到代碼的錯誤消息發生。在我的代碼中,我試圖執行註銷功能。對於這個註銷功能,我已經準備好註銷xpath正確存儲的excel。但是當我試圖執行此代碼時會出現錯誤消息。錯誤消息是元素在點(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);
}
}
}
在你的代碼,這行拋出此消息?我們可以擁有網站的網址嗎? –
當我嘗試點擊註銷功能,然後出現錯誤消息。註銷函數xpath寫入excel sheet.Site url-117.247.65.9/vms_test。 username-msrtc,password-Admin。共享Excel數據 - Methodname - ClickLink,Data1 - // a [包含(text(),'Logout')],Data2 - 不需要,Data3 - 不需要。 – Arijit
它看起來註銷按鈕的xpath可能是正確的,但有一些其他元素(如通知/彈出窗口)覆蓋該註銷按鈕。可以幫助你更好,如果你給URL @ –