Problems while trying to crawl with scrapy/splash? - scrapy

I am interested in crawl a website, and at first instance I would like to get the links from this section of the website:
<div id="lo-mas-visto">
<div class="item seccion-nacion">
<span class="fecha">04:21</span>
<span class="title">
Tras videoescándalo cae candidata de Morena
</span>
</div>
<div class="item seccion-nacion">
<span class="fecha">02:01</span>
<span class="title">
</div>
<div class="item seccion-mundo">
<span class="fecha">03:20</span>
<span class="title">
Trump se rinde; no incluye muro en presupuesto
</span>
</div>
<div class="item seccion-nacion">
<span class="fecha">02:02</span>
<span class="title">
AMLO y el dinero sucio
</span>
</div>
<div class="item seccion-nacion">
<span class="fecha">02:06</span>
<span class="title">
Morena y los nuevos videoescándalos
</span>
</div>
<div class="item seccion-metropoli">
<span class="fecha">01:09</span>
<span class="title">
Delfina Gómez y su equipo se premian con bonos
</span>
</div>
<div class="item seccion-metropoli">
<span class="fecha">01:06</span>
<span class="title">
Van tras mujer que prostituye a niñas de secundaria y prepa
</span>
Hence, I tried to implement a spider for pulling such info:
# -*- coding: utf-8 -*-
import scrapy
from scrapy_splash import SplashRequest
class OpinionsSpider(scrapy.Spider):
name = "news"
allowed_domains = ["http://www.eluniversal.com.mx/"]
start_urls = ['http://www.eluniversal.com.mx/']
def start_requests(self):
for url in self.start_urls:
yield SplashRequest(url, self.parse, args={'wait': 0.5})
def parse(self, response):
#print(response.body)
item = {
'url' : response.xpath(".//*[#id='lo-mas-visto']//div//span//a")
}
yield item
The problem is that I am not getting the urls from the above object:
user#MacBook-Pro-de-User-3:~/PycharmProjects$ scrapy runspider opinions.py
2017-04-27 17:09:28 [scrapy.utils.log] INFO: Scrapy 1.3.3 started (bot: scrapybot)
2017-04-27 17:09:28 [scrapy.utils.log] INFO: Overridden settings: {'SPIDER_LOADER_WARN_ONLY': True}
2017-04-27 17:09:28 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
'scrapy.extensions.telnet.TelnetConsole',
'scrapy.extensions.logstats.LogStats']
2017-04-27 17:09:29 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
'scrapy.downloadermiddlewares.retry.RetryMiddleware',
'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
'scrapy.downloadermiddlewares.stats.DownloaderStats']
2017-04-27 17:09:29 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
'scrapy.spidermiddlewares.referer.RefererMiddleware',
'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
'scrapy.spidermiddlewares.depth.DepthMiddleware']
2017-04-27 17:09:29 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2017-04-27 17:09:29 [scrapy.core.engine] INFO: Spider opened
2017-04-27 17:09:29 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2017-04-27 17:09:29 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2017-04-27 17:09:29 [scrapy.core.engine] DEBUG: Crawled (200) <GET http://www.eluniversal.com.mx/> (referer: None)
2017-04-27 17:09:29 [scrapy.core.scraper] DEBUG: Scraped from <200 http://www.eluniversal.com.mx/>
{'url': []}
2017-04-27 17:09:29 [scrapy.core.engine] INFO: Closing spider (finished)
2017-04-27 17:09:29 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 220,
'downloader/request_count': 1,
'downloader/request_method_count/GET': 1,
'downloader/response_bytes': 53389,
'downloader/response_count': 1,
'downloader/response_status_count/200': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2017, 4, 27, 22, 9, 29, 901099),
'item_scraped_count': 1,
'log_count/DEBUG': 3,
'log_count/INFO': 7,
'response_received_count': 1,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2017, 4, 27, 22, 9, 29, 143023)}
2017-04-27 17:09:29 [scrapy.core.engine] INFO: Spider closed (finished)
How can I fix the spider in order to get the links, and start a pagination scheme?...

From the comments, I think your problem is that you don't have a scrapy project and splash is not correctly configured. Your spider does not render the JavaScript, so you can't acces the links you want.
Also your xpath is missing /#href at the end if you want to extract links.
Here is a very usefull tool if you want to test your xpaths: videlibri.
You first need to make a scrapy project (startproject).
Then you need to configure correctly splash so you can render the JavaScript from the website and get the links you want. Here is the documentation you need: scrapy_splash
Hope this helps.

Related

Caused by: org.openqa.selenium.InvalidSelectorException:

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();
}

Selenium says element is not visible when it is with latest Firefox (ElementNotInteractableException: Element is not visible)

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.

Element is not clickable at point ... with selenium 2 and WebDriver

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.

Selenium Error:I am using selenium webdriver in maximo for testing but some error

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (413, 63). Other element would receive the click: <div id="wait" width="100%" height="100%" class="wait" style="position: absolute; top: 0px; left: 0px; height: 666px; width: 1366px; display: block; cursor: wait;">...</div>
(Session info: chrome=53.0.2785.143)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 94 milliseconds
Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700'
System info: host: 'ICDVM', ip: '10.0.0.11', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\Users\ADMINI~1\AppData\Local\Temp\scoped_dir16420_7494}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=53.0.2785.143, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: e24f7435d75ad5ddbecb362090ddb0a3
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:631)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:284)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at script.Script.main(Script.java:78)
For what its worth, there is an element with a wait class overlaying the element you are trying to click.

How do I check enable and disabled button using helium?

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;
}
}