I am new in Selenium automation testing Getting Selenium Error
When I am trying to run below code every time I got error"org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath" I am not sure what xpate will be could some one please help me Created Automation test case for Login Application.
Java:
@Test
public void enterApplicationCerdentials(String userName, String password) {
WebDriverWait wait = new WebDriverWait(driver, 50);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//frameset/frame/html/body/div([@class='tintedBox' and @id='loginBox']/table/tbody/tr/td/input[@id='UserID' and name='UserID'])"))).sendKeys(userName);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Password"))).sendKeys("CSRWHKXESB");
captureScreen();
}
HTML:
<frameset rows="*, 1">
<frame src="Script/Login.asp?">
#document
<!--Function return the password for the user who logged in through Referral URL.
For TAFE user password is not matching as per database value as their URL is dynamic. ENHC0014091
This function splits the URL of that particular user (8527066229) only . -->
<html><head>
<script language="JavaScript">
//<!--
function OnLoad()
{
setTimeout("CheckFrame()", 4000);
}
function CheckFrame()
{
with (parent)
{
if ((length==0 && document.frmCheck==null) ||
(length>0 && frames[1].document.frmCheck==null))
{
var PathName = window.location.pathname;
PathName = PathName.substr(0, PathName.substr(1).indexOf("/") + 1);
location.href = PathName;
}
}
}
//-->
</script></head>
<body onload="OnLoad()" topmargin="0" leftmargin="0" bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000">
<div id="login">
<img border="0" src= vspace="10" style="display: block;">
<div class="tintedBox" id="InfoStoreBox">
<h1> <a class="boldLink" href="https://infostore.saiglobal.com" target="_parent"><u>InfoStore</u></a> ?</h1>
<p></p>
<p><a class="boldLink" href="https://infostore.saiglobal.com" target="_parent"></a> .</p>
<p>Not only a shop, <a class="boldLink" href="https://infostore.saiglobal.com" target="_parent"></a> </p>
<p><a href="https://infostore.saiglobal.com" target="_parent"></a></p>
</div>
<div class="tintedBox" id="loginBox">
<h1></h1>
<form name="form" action="Login.asp?" method="post">
<input type="hidden" name="Autologout" value="false">
<input type="hidden" name="Division" value="">
<span class="error"></span>
<table>
<tbody><tr>
<td>User ID</td>
<td><input type="text" size="30" id="UserID" name="UserID" value=""></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" size="30" id="Password" name="Password" value=""></td>
</tr>
<tr>
<td>Last Name/Location</td>
<td><input type="text" size="30" id="UserName" name="UserName" value=""></td>
</tr>
</tbody></table>
<br>
<font color="#d12b2c"><nobr>Your Last Name and Location are now mandatory to access the platform, simply</nobr><br>enter the details in field (e.g. Smith/Perth)</font>
<br><br>
<div>
<input type="checkbox" id="SaveLogin" name="SaveLogin" value="SaveLogin"><label for="SaveLogin" id="save">Save my login so you can remember me on my next visit.</label>
</div>
<div align="center" style="padding-top:20px">
<input class="button" type="submit" name="Submit" value="Submit">
<input class="button" type="reset" name="Clear" value="Clear">
<input class="button" type="submit" name="Recognize" value="Remember me?">
</div>
<div style="padding-top:20px">
<nobr>Lost password? Contact your internal Administrator or <a class="boldLink" href="mailto:[email protected]?subject=Lost SOL password">our Customer Service</a></nobr>
</div>
</form>
</div>
</div>
<div id="footer" onmouseover="ShowTime()">©2014 SAI Global</div>
<script>
function ShowTime()
{
var spTime = document.getElementById("footer");
spTime.innerHTML = "©2014 SAI Global - 20190426 12:25:33.292: 172.20.33.12, 203.27.21.6, 59596377";
}
</script>
</body></html>
Error:
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: //frameset/frame/html/body/div([@class='tintedBox' and @id='loginBox']/table/tbody/tr/td/input[@id='UserID' and name='UserID']) (tried for 50 second(s) with 500 milliseconds interval) at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272) at seleniumPages.Page_LoginMyApplication.enterApplicationCerdentials(Page_LoginMyApplication.java:67) at stepDefinitions.StepDefs_DataDrivenLogin.i_login_with_credentials_and(StepDefs_DataDrivenLogin.java:23) at ?.I login with credentials "tomsmith" and "***************"(resources/features/DataDrivenLogin.feature:7) Caused by: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //frameset/frame/html/body/div([@class='tintedBox' and @id='loginBox']/table/tbody/tr/td/input[@id='UserID' and name='UserID']) because of the following error: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//frameset/frame/html/body/div([@class='tintedBox' and @id='loginBox']/table/tbody/tr/td/input[@id='UserID' and name='UserID'])' is not a valid XPath expression. (Session info: chrome=73.0.3683.103) (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/invalid_selector_exception.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'AP01154W8N', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.46.628402 (536cd7adbad73a..., userDataDir: C:\Users\sinham0\AppData\Lo...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:65139}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 73.0.3683.103, webStorageEnabled: true} Session ID: 869efd2308887ee98e8d561566b5a606 *** Element info: {Using=xpath, value=//frameset/frame/html/body/div([@class='tintedBox' and @id='loginBox']/table/tbody/tr/td/input[@id='UserID' and name='UserID'])} at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)