当我试图运行代码然后出现错误消息
问题描述:
当我试图运行下面提到代码的错误消息发生。在我的代码中,我试图执行注销功能。对于这个注销功能,我已经准备好注销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);
}
}
}
答
您需要等待loading_bg直到屏幕熄灭。请更新下面给出的方法clickLink。请尝试让我们知道。
public void clickLink(String xPath,String nr,String nr1,WebDriver fd){
new WebDriverWait(fd, 90).until(ExpectedConditions.invisibilityOfElementLocated(By.id("loading_bg")));
element = fd.findElement(By.xpath(xPath));
element.click();
}
在你的代码,这行抛出此消息?我们可以拥有网站的网址吗? –
当我尝试点击注销功能,然后出现错误消息。注销函数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 @ –