The code of attached button is:
<div style="position: absolute; right: 0; top: 0;">
<button class="prev btn btn-warning disabled" style="padding: 4px 8px;">
<i class="fa fa-chevron-left" style="margin: 0"/>
</button>
<button class="next btn btn-warning" style="padding: 4px 8px;">
<i class="fa fa-chevron-right" style="margin: 0"/>
</button>
</div>
How can I check that which one is enable using helium
I tried the following code
click("Home");
if(Button(">").isEnabled()){
click($("html/body/div[6]/div/h3/div/button[2]"));
}
else{
click($("html/body/div[6]/div/h3/div/button[1]"));
}
But got the following error
Exception in thread "main" org.openqa.selenium.NoSuchElementException:
Cannot find element ButtonImpl(">").
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27
09:10:26'
System info: host: 'Keya-PC', ip: '172.16.0.144', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version:
'1.8.0_25'
Driver info: driver.version: unknown
at com.heliumhq.api_impl.GUIElementImpl.perform(GUIElementImpl.java:107)
at com.heliumhq.api_impl.GUIElementImpl.bindToFirstOccurrence(GUIElementImpl.java:94)
at com.heliumhq.api_impl.GUIElementImpl.getFirstOccurrence(GUIElementImpl.java:89)
at com.heliumhq.api_impl.ButtonImpl.isEnabled(ButtonImpl.java:26)
at com.heliumhq.API$Button.isEnabled(API.java:1276)
at searchHomePage.search(searchHomePage.java:30)
at mainClass.main(mainClass.java:19)
error: Cannot find element ButtonImpl(">")
We need to check the presence of the class (prev btn btn-warning disabled or next btn btn-warning ) in the code.
element ">" is not on the page is a picture.
UPD:
if (driver.findElements(By.xpath("someXpath")).size == 0)
or
$(By.xpath("someXpath")).shouldNotBe(visible);
Code in Java:
public static boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
Related
there is a pop up after adding item to cart but it does not pop sometimes
how can i have the loop, if there is pop up then click the close or continue button or just click the background to dismiss it.
if it does not pop then continue next step.
below is the element, it is pretty long. please help to check
<div class="a-popover-wrapper"><header class="a-popover-header"><h4 class="a-popover-header-content" id="a-popover-header-6">Add to Order</h4><button data-action="a-popover-close" class=" a-button-close a-declarative" aria-label="Close"><i class="a-icon a-icon-close"></i></button></header><div class="a-popover-inner" id="a-popover-content-6" style="height: auto; overflow-y: auto;">
<div id="abb-interstitial" class="a-section abb-interstitial">
<div id="abb-intl-product-view-B07KTYTTG9" class="a-section abb-intl-product-view" style="display: block;">
<!-- only true in interstitial popovers -->
<div class="a-row">
<div class="a-column a-span4 a-text-center abb-product-view-image-container">
<img src="https://images-na.ssl-images-amazon.com/images/I/31STSohmOiL._SL160_.jpg" class="a-image-wrapper a-manually-loaded abb-product-image" id="" alt="" data-a-image-source="https://images-na.ssl-images-amazon.com/images/I/31STSohmOiL._SL160_.jpg" data-a-hires="https://images-na.ssl-images-amazon.com/images/I/31STSohmOiL._SL500_.jpg">
</div>
<div class="a-column a-span8 a-span-last">
<h3 class="a-spacing-none">
<a class="a-link-normal abb-product-title" target="_blank" rel="noopener" href="/dp/B07KTYTTG9/ref=ods_dabb_B07KTYTTG9_productInfo">
AppleCare+ for 13-inch MacBook Pro (3 Years)
</a>
</h3>
<div class="a-section a-spacing-micro abb-product-merchant-container">
<span class="a-color-secondary">
from
<span class="abb-product-merchant">Amazon Digital Services LLC</span>
</span>
</div>
<div class="a-section a-spacing-micro abb-product-reviews">
<style type="text/css">
/*
* Fix for UDP-1061. Average customer reviews has a small extra line on hover
* https://omni-grok.amazon.com/xref/src/appgroup/websiteTemplates/retail/SoftlinesDetailPageAssets/udp-intl-lock/src/legacy.css?indexName=WebsiteTemplates#40
*/
.noUnderline a:hover {
text-decoration: none;
}
</style>
<div id="averageCustomerReviews" class="a-spacing-none" data-asin="B07KTYTTG9" data-ref="dpx_acr_pop_">
<span class="a-declarative" data-action="acrStarsLink-click-metrics" data-acrstarslink-click-metrics="{}">
<span id="acrPopover" class="reviewCountTextLinkedHistogram noUnderline" title="4.0 out of 5 stars">
<span class="a-declarative" data-action="a-popover" data-a-popover="{"max-width":"700","closeButton":"false","position":"triggerBottom","url":"/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=B07KTYTTG9"}">
<a href="javascript:void(0)" class="a-popover-trigger a-declarative">
<i class="a-icon a-icon-star a-star-4"><span class="a-icon-alt">4.0 out of 5 stars</span></i>
<i class="a-icon a-icon-popover"></i></a>
</span>
<span class="a-letter-space"></span>
</span>
</span>
<span class="a-letter-space"></span>
<span class="a-declarative" data-action="acrLink-click-metrics" data-acrlink-click-metrics="{}">
<a id="acrCustomerReviewLink" class="a-link-normal" href="#customerReviews">
<span id="acrCustomerReviewText" class="a-size-base">2 customer reviews</span>
</a>
</span>
<script type="text/javascript">
P.when('A', 'ready').execute(function(A) {
A.declarative('acrLink-click-metrics', 'click', { "allowLinkDefault" : true }, function(event){
if(window.ue) {
ue.count("acrLinkClickCount", (ue.count("acrLinkClickCount") || 0) + 1);
}
});
});
</script>
<script type="text/javascript">
P.when('A', 'cf').execute(function(A) {
A.declarative('acrStarsLink-click-metrics', 'click', { "allowLinkDefault" : true }, function(event){
if(window.ue) {
ue.count("acrStarsLinkWithPopoverClickCount", (ue.count("acrStarsLinkWithPopoverClickCount") || 0) + 1);
}
});
});
</script>
</div>
</div>
<div class="a-section a-spacing-base abb-product-price">
<span class="a-size-medium a-color-secondary abb-product-list-price a-text-strike">
</span>
<span class="a-size-medium a-color-price abb-product-buying-price">
$269.00
</span>
</div>
<div class="a-section abb-product-feature-bullets">
<ul>
<li>AppleCare product must be purchased with an applicable Apple device. Terms & Conditions will be delivered via email post-enrollment and can be downloaded through your Digital Items Page (Your Account-->Games and Software).</li>
<li>AppleCare+ will automatically be enrolled at time of purchase, and Proof of Coverage will be emailed within 3 days after your device ships.</li>
<li>AppleCare+ for Mac extends your coverage to three years from your AppleCare+ purchase date and adds up to two incidents of accidental damage coverage</li>
<li>Each incident of accidental damage coverage is subject to a service fee of $99 for screen damage or external enclosure damage, or $299 for other damage, plus applicable tax</li>
<li>Get 24/7 priority access to Apple experts by chat or phone</li>
<li>Onsite repair for desktop computers: Request that a technician come to your work site</li>
<li>Mail-in repair for portable computers: Mail in your Mac using a prepaid shipping box provided by Apple</li>
<li>Carry-in repair: Take your Mac to an Apple Store or other Apple Authorized Service Provider</li>
<li>Hardware coverage for your Mac computer, battery, included accessories such as the power adapter, Apple memory (RAM), AirPort, and Apple USB SuperDrive</li>
<li>Software support for using macOS and iCloud, quick how-to questions about Apple-branded apps, such as Photos, iMovie, GarageBand, Pages, Numbers, Keynote, and more, connecting to printers and AirPort networks</li>
</ul>
</div>
</div>
</div>
<div class="a-row">
<div class="a-column a-span8 a-push4">
<div class="a-section a-spacing-mini a-spacing-top-base abb-intl-product-cta">
<div class="a-row a-spacing-top-base">
<div data-asin="B07KTYTTG9" class="a-checkbox abb-intl-product-ato"><label><input type="checkbox" name="" value="" autocomplete="off"><i class="a-icon a-icon-checkbox"></i><span class="a-label a-checkbox-label">
<span class="a-text-bold">Add AppleCare+ for 13-inch MacBook Pro (3 Years) to your order</span>
</span></label></div>
</div>
</div>
</div>
</div>
</div>
<div id="abb-intl-pop-cta" class="a-section a-spacing-base">
<div class="a-row">
<div class="a-column a-span8 a-push4">
<span class="a-button a-button-primary abb-intl-ato abb-intl-continue" id="a-autoid-13"><span class="a-button-inner"><input class="a-button-input" type="submit" aria-labelledby="a-autoid-13-announce"><span class="a-button-text a-text-center" aria-hidden="true" id="a-autoid-13-announce">
Continue
</span></span></span>
<span class="a-button a-button-base abb-intl-decline aok-hidden" id="a-autoid-14"><span class="a-button-inner"><input class="a-button-input" type="submit" aria-labelledby="a-autoid-14-announce"><span class="a-button-text a-text-center" aria-hidden="true" id="a-autoid-14-announce">
No thanks
</span></span></span>
</div>
</div>
</div>
</div>
</div></div>
Try the following code.Hope this will work.
To click on continue try this
if (driver.findElements(By.cssSelector("div.a-popover-wrapper")).size()>0){
WebElement element=driver.findElement(By.Xpath("//span[normalize-space(.)='Continue']/parent::span/input[#class='a-button-input']"));
Actions action = new Actions(driver);
action.moveToElement(element).click().build().perform();
}
OR
if (driver.findElements(By.cssSelector("div.a-popover-wrapper")).size()>0){
WebElement element=driver.findElement(By.Xpath("//span[normalize-space(.)='Continue']/parent::span/input[#class='a-button-input']"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();",element);
}
//To click on No Thanks try this
if (driver.findElements(By.cssSelector("div.a-popover-wrapper")).size()>0){
WebElement element=driver.findElement(By.Xpath("//span[normalize-space(.)='No thanks']/parent::span/input[#class='a-button-input']"));
Actions action = new Actions(driver);
action.moveToElement(element).click().build().perform();
}
OR
if (driver.findElements(By.cssSelector("div.a-popover-wrapper")).size()>0){
WebElement element=driver.findElement(By.Xpath("//span[normalize-space(.)='No thanks']/parent::span/input[#class='a-button-input']"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();",element);
}
//To close the popup
if (driver.findElements(By.cssSelector("div.a-popover-wrapper")).size()>0){
WebElement element=driver.findElement(By.cssSelector("i.a-icon.a-icon-close"));
Actions action = new Actions(driver);
action.moveToElement(element).click().build().perform();
}
OR
if (driver.findElements(By.cssSelector("div.a-popover-wrapper")).size()>0){
WebElement element=driver.findElement(By.cssSelector("i.a-icon.a-icon-close"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();",element);
}
Here is the logic.
// change the action based on scenario
String action = 'Continue';
if (driver.findElements(By.Xpath("//div[#class='a-popover-wrapper']")).size()>0){
driver.findElement(By.Xpath("//div[#class='a-popover-wrapper']//span[#class='a-button-text a-text-center' and normalize-space(.)='" + action + "']")).click();
}
I am using python:
def escape_pop(driver):
try:
if len(str(driver.find_element_by_class_name("a-popover-wrapper"))) > 0: # check if popup is present
actions = ActionChains(driver)
actions.send_keys(Keys.ESCAPE).perform()
except:
pass
after trying many methods.
below is working.
i add a wait element
then add one more click.
WebDriverWait wait2 = new WebDriverWait(driver, 10);
wait2.until(ExpectedConditions.elementToBeClickable(By.id("a-autoid-13")));
driver.findElement(By.cssSelector("i.a-icon.a-icon-close")).click();
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></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:sales#saiglobal.com?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)
The reason you are getting TimeoutException is that the element you are finding is in a frame and you have to switch to that frame. Otherwise, webdriver can't find the element.
First, find the appropriate selector for the frame tag. According to your provided HTML I'm constructing the locator.
XPath:
WebElement loginFrame = driver.findElement(By.xpath("//frameset/frame[#src='Script/Login.asp?']"));
CSS Selector:
WebElement loginFrame = driver.findElement(By.cssSelector("frameset > frame[src='frame_c.htm']"));
Try this:
#Test
public void enterApplicationCerdentials(String userName, String password) {
WebDriverWait wait = new WebDriverWait(driver, 50);
By frameLocator = By.xpath("//frameset/frame[#src='Script/Login.asp?']");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//frameset/frame[#src='Script/Login.asp?']")));
driver.switchTo().frame(driver.findElement(frameLocator));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("UserName"))).sendKeys("UserName");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Password"))).sendKeys("Password");
captureScreen();
}
On our test page we have a username field and a password field as follows:
<input required="" placeholder="USERNAME" id="usernameIdentification"
class="form-control no-upper-case autoExpand textValidation"
autofocus="autofocus" autocapitalize="none" autocorrect="off"
spellcheck="false" size="20" type="text">
<input id="password" name="password" placeholder="PASSWORD" class="form-
control no-upper-case autoExpand textValidation" required="required"
autofocus="" autocomplete="password" autocapitalize="none"
autocorrect="off" spellcheck="false" type="password" hidden="true">
The username field is filled out by selenium, we hit a next button and the next page has the password field.
Using: Firefox version 46.0.1 and Selenium version 2.53.1
The following code was working fine:
//Enter username
WebElement userField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("usernameIdentification")));
userField.sendkeys(username);
//Press next button
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("nextButton"))).click();
//Fill password
WebElement passwordField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("password")));
passwordField.sendKeys(password);
When I update to: Firefox version 57, and selenium 3.7.1, with geckodriver 0.19.1
The code breaks, selenium will not enter text into the password field anymore, I can manually enter the password without issue, but selenium keeps insisting that the field is not visible, even though the wait check passed right before the send keys and the username field has no issues entering the text. I get this error:
> org.openqa.selenium.ElementNotInteractableException: Element is not
> visible Build info: version: '3.7.1', revision: '8a0099a', time:
> '2017-11-06T21:01:39.354Z' System info: host: 'D2QZ7XF2', ip:
> '10.122.22.31', os.name: 'Windows 10', os.arch: 'amd64', os.version:
> '10.0', java.version: '1.8.0_151' Driver info:
> org.openqa.selenium.firefox.FirefoxDriver Capabilities
> {acceptInsecureCerts: true, browserName: firefox, browserVersion:
> 57.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 15884, moz:profile:
> C:\Users\dcollier\AppData\L..., moz:webdriverClick: false,
> pageLoadStrategy: normal, platform: XP, platformName: XP,
> platformVersion: 10.0, rotatable: false, timeouts: {implicit: 0,
> pageLoad: 300000, script: 30000}} Session ID:
> b2f9536b-23ce-4c0f-93d5-cfe46d82228d
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method) at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
> at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
> at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
> at
> org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
> at
> org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
> at
> org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
> at
> org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
> at
> org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
I also tested with latest Chrome driver and it worked fine there as well. But we need to use firefox profiles, so i need this to work there. Appears to be an issue with the gecko driver, has anyone encountered this, know of a solution? I tried several approaches but it never works.
I'm trying to select a tab on webpage created using extjs. FirePath is highlighting the tab correctly but click event is not working. Selenium is throwing element not visible error.
Exception in thread "main"\org.openqa.selenium.ElementNotVisibleException: element not visible
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.1.7601 SP1 x86_64)
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 38 milliseconds
Here is the HTML code:
I'm trying to select a Tab titled Details with id as tabDetail.
<a class="x-tab x-unselectable x-box-item x-tab-default x-noicon x-tab-noicon x-tab-default-noicon x-top x-tab-top x-tab-default-top x-tab-after-title" role="button" hidefocus="on" unselectable="on" tabindex="0" id="tabDetail" style="right: auto; left: 143px; top: 0px; margin: 0px;">
<span id="tabDetail-btnWrap" class="x-tab-wrap" unselectable="on">
<span id="tabDetail-btnEl" class="x-tab-button">
<span id="tabDetail-btnInnerEl" class="x-tab-inner x-tab-inner-center" unselectable="on">
Detail
</span>
<span role="img" id="tabDetail-btnIconEl" class="x-tab-icon-el " unselectable="on" style="">
</span>
</span>
</span>
</a>
You need to wait until element is visible. Use explicit wait -
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[2]")));
// Now click on element
driver.findElement(By.xpath("//div[2]")).click();
today I searched a lot and found lots of information, but nothing helped.
I use selenium-java-2.53.1 and FF47 and face the following problem:
Exception in thread "main" org.openqa.selenium.WebDriverException: Element is not clickable at point (779.5, 12.199996948242188). Other element would receive the click: <header class="header"></header>
Command duration or timeout: 106 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'spa-PC', ip: '192.168.5.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_74'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=47.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: c897bef8-b708-45f3-a991-5cf8971939c8
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85)
It happens when I running this code:
WebElement elementToClick = driver.findElement(By.xpath("//div[#class='show show-hide-accounts-button']"));
elementToClick.click();
And use this part of HTML:
<div class="trader-wrapper">
<a class="avatar-frame-small" href="/bg/traders/5d2f970c-56e9-4ca1-99de-13ecb266bc82">
<span class="flag flag-lt" title="Литва"></span>
<a class="profile-link" href="/bg/traders/5d2f970c-56e9-4ca1-99de-13ecb266bc82">
<div class="trader-current-time">
<div class="accounts-summary">
<button class="follow-trader-ribbon" title="Start receiving trading activity updates from this Trader" data-user-name="Justinas Miezis" data-follow="53121">Follow </button>
<table class="trader-info">
<div class="gain-chart-wrapper trader">
<div class="clear"></div>
<div class="show show-hide-accounts-button">Show account</div>
<div class="angled-separator top">
<div class="trader-accounts">
<div class="angled-separator bottom"></div>
</div>
Does somebody have workaround for this problem?
Thank you in advance.