2017-04-24 29 views
-2

在給Xpath登錄後,當我通過硒測試腳本時,無法點擊登錄按鈕。 情景 - •通過提供用戶名和密碼登錄到應用程序。執行測試腳本時無法使用硒點擊登錄按鈕

public class Myclass { 

    public static void main(String[] args) throws IOException, InterruptedException { 
    System.setProperty("webdriver.gecko.driver","C:\\Users\\karokiaswamy\\Documents\\Selenium_installation\\geckodriver-v0.15.0-win64\\geckodriver.exe"); 
    WebDriver driver = new FirefoxDriver(); 
    Runtime.getRuntime().exec("c:\\autoit\\HandleAuth.exe"); 
    driver.get("Application URL"); 
    //Runtime.getRuntime().exec("C:\\autoit\\HandleAuth.exe"); 
    Thread.sleep(1000); 
    driver.get("Application URL"); 
    driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[1]/input")).clear(); 
    driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[1]/input")).sendKeys("testtrack"); 
    driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[2]/input")).clear(); 
    driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[2]/input")).sendKeys("password01"); 
    driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[3]/button")).clear(); 
    driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[2]/input")).sendKeys(" "); 
    driver.findElement(By.xpath("///button[@class ='btnSmall btnGreen']")).click(); 
    //driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[3]/button")).click() 
    } 
} 
+0

複製您的登錄頁面的HTML,如果可能的 –

+0

你能否提供更多的信息:1。什麼是你通過'調用Runtime.getRuntime()做的exec(「C: \\ autoit \\ HandleAuth.exe「);'? 2.你能爲該網站提供有效的憑據嗎? – DebanjanB

+0

@ venkatasiva - Runtime.getRuntime().exe(「c:\\ autoit \\ HandleAuth.exe」)用於在導航到應用程序之前爲Authentication alert提供用戶名和密碼。 –

回答

0

如果我理解你,你點擊登錄按鈕後會得到一個異常。 如果你做,你可以用JavaScript點擊如下:

JavascriptExecutor js = (JavascriptExecutor)driver; 
js.executeScript("arguments[0].click()", element);