2017-06-22 103 views
0

当我试图运行下面提到代码的错误消息发生。在我的代码中,我试图执行注销功能。对于这个注销功能,我已经准备好注销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); 
     } 


    } 

} 
+0

在你的代码,这行抛出此消息?我们可以拥有网站的网址吗? –

+0

当我尝试点击注销功能,然后出现错误消息。注销函数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

+0

它看起来注销按钮的xpath可能是正确的,但有一些其他元素(如通知/弹出窗口)覆盖该注销按钮。可以帮助你更好,如果你给URL @ –

回答

0

您需要等待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(); 

}

+0

@感谢Murti ..你的代码正常工作。非常感谢,谢谢。问你一件事什么是loading_bg。此加载_bg显示在错误消息中。如果可能的话,请回复。 – Arijit

+0

这是一个用于加载背景的ID,用于在完成一些后台进程之前阻止UI。你需要等待。一些应用程序,它会加载栏/符号。我不知道你的应用程序。 – Murthi

+0

感谢@Murthi您的杰出解释和您的帮助。那意义重大。再次感谢。现在这个代码正常工作。 – Arijit

相关问题