Rip's Domain

Selenium and ElementNotVisibleException: One rule to keep yourself from going insane

Posted in Uncategorized by rip747 on April 5, 2014

I’m working on a project using Selenium and C#. Though really cool as hell, I have to say its nothing short of frustrating.

Take for instance the following error:

OpenQA.Selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with.

That little error took me an hour to figure out why it was happening. For some reason I would get this error when I was running my console app by double clicking on it, however i wouldn’t get the error when launching it through a schedule task.

The issue turned out to be something I completely overlooked and probably a golden rule when using Selenium:

“If you can’t see it, Selenium can’t click it”

So what doesn’t that mean exactly? In other words when I was running my application by launching it myself; firefox would open, go to the page and Selenium would attempt to click a button on the page. Turns out that even though the button was “physically” on the page, it was covered by some stupid static overlay hugging the bottom of the screen because of the window size. I only figured it out after I paused Selenium (using Thread.Sleep(5000);)  and manually scrolled the page down so I could physically see the button myself in the browser window.

Now it all made sense why everything was blowing up when I was running the application myself, but it would work fine through a scheduled tasks. I’m guessing through a schedule task, the browser is invoked headless so this whole “physically seeing” elements and browser window size doesn’t apply. Selenium must just see the page as whole since it doesn’t have the restriction of the browser window.

In the end, the way I got it all to work by forcing the page to scroll to the bottom using the IJavaScriptExecutor like so:

IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;
jse.ExecuteScript(“window.scrollTo(0, document.body.scrollHeight);”);

 

By default, Selenium will automatically scroll the window to the element in order to make sure that it is visible in the browser window, however, because of this overlay, it actually needed to scroll about 100px more down the page in order for the element to actually be visible in the browser. Scrolling to the bottom was a hack, but it worked.

cfindex: Warn E0-1514 (Drvr): TstrIOFilter:flt_kv: KV failed on filtering document: error = 8 on PDFs

Posted in Uncategorized by rip747 on December 3, 2013

Solved this problem by removing a “PRINT FORM” button that would automatically print the form when hovered on

cfindex: Warn E0-1514 (Drvr): TstrIOFilter:flt_kv: KV failed on filtering document: error = 6 when indexing PDFs

Posted in Uncategorized by rip747 on December 3, 2013

What solved this issue for me was removing any security the PDF had on it. In this case the PDF has password security enabled

Android: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

Posted in Uncategorized by rip747 on April 5, 2013

When trying to launch our android application onto the emulator through eclipse, i get the following error:

04-05 15:12:24.082: E/AndroidRuntime(386): FATAL EXCEPTION: main

04-05 15:12:24.082: E/AndroidRuntime(386): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.sheriff/org.sheriff.BizTownActivity}: java.lang.ClassNotFoundException: org.sheriff.BizTownActivity in loader dalvik.system.PathClassLoader[/data/app/org.sheriff-2.apk]

04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1739)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.access$500(ActivityThread.java:122)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.os.Looper.loop(Looper.java:132)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.main(ActivityThread.java:4123)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.reflect.Method.invoke(Method.java:491)
04-05 15:12:24.082: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-05 15:12:24.082: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-05 15:12:24.082: E/AndroidRuntime(386): at dalvik.system.NativeStart.main(Native Method)
04-05 15:12:24.082: E/AndroidRuntime(386): Caused by: java.lang.ClassNotFoundException: org.sheriff.BizTownActivity in loader dalvik.system.PathClassLoader[/data/app/org.sheriff-2.apk]
04-05 15:12:24.082: E/AndroidRuntime(386): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.ClassLoader.loadClass(ClassLoader.java:540)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.ClassLoader.loadClass(ClassLoader.java:500)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1730)
04-05 15:12:24.082: E/AndroidRuntime(386): … 11 more

 

After searching through StackOverflow and Google. I couldn’t come up with an answer. For some reason I had a look at my .classpath file and noticed something:

<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” path=”gen”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.ANDROID_FRAMEWORK”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.LIBRARIES”/>
<classpathentry kind=”output” path=”bin/classes”/>
</classpath>

If you look closely you’ll notice that there isn’t a classpathentry for src directory itself where org.sheriff.BizTownActivity is located. I changed the .classpath to reflect the src path:

<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” path=”src”/>
<classpathentry kind=”src” path=”gen”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.ANDROID_FRAMEWORK”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.LIBRARIES”/>
<classpathentry kind=”output” path=”bin/classes”/>
</classpath>

and it worked!!!

Tagged with:

ColdFusion 9 64-bit / IIS7.5 / Windows 7 / 500 error

Posted in Uncategorized by rip747 on December 23, 2012

Quick note about setting up ACF9 on Windows 7 and IIS 7.5. In order to get everything working, you need to install the following:

http://download.macromedia.com/pub/coldfusion/cf9_installer/ColdFusion_9_WWEJ_win64.exe

http://download.macromedia.com/pub/coldfusion/updates/901/ColdFusion_update_901_WWEJ_win64.exe

http://helpx.adobe.com/coldfusion/kb/cumulative-hot-fix-2-coldfusion-1.html

In other words, you need to install the base install, the CF 9.0.1 update and the CF 9.0.1 Hot Fix 2. The Hot Fix is probably the most important as if you only install the base and then the update, you will receive a 500 error when trying to access any site running CF especially the CF Administrator.

RailsTutorial.org problems

Posted in Uncategorized by rip747 on June 2, 2012

below are some of the problems I’ve been having while following the railstutorial.org screencasts. These are in no particular order and may only pertain to my system, but I thought that I would document them here in case others run into them. Also, I’m going by the information that is provided in the screencasts themselves. During the screencasts, there are several time where the author refers to the online book in order to get the proper configuration. Most people are not going to take the time to search through the book to get the proper configuration to follow along in the screencasts. Hopefully this post will help people along when following the screencast and prevent them from having to refer to the book.

Lesson 1

when pushing to heroku, you will receive the following error:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’
or ‘yum install sqlite-devel’ and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

basically this means that heroku couldn’t compile the sqlite gem. You Gemfile should have the following in it if you’re following along:


source 'https://rubygems.org'

gem 'rails', '3.2.5'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
 gem 'sass-rails', '~> 3.2.3'
 gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
 # gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

To fix, you need to make it so that the sqlite gem is not installed in production. to do this add change the `gem ‘sqlite3’` line in your Gemfile to the following:


gem 'sqlite3', :group => [:development, :test]

Lesson 3

When running the tests from with ruby you receive the error `/bin/sh: rspec: command not found` Basically this is cause because you having started SublimeText from the command line and don’t have `~/bin` in your path. To add `~/bin` to your path open up your .bash_profile file in an editor. WARNING! During the installation tutorial, you installed RVM so that you can manage your ruby installation. This causes a major problem because creating a `.bash_profile` to allow you to edit your path will cause rvm to break, which will result in rails to break. In order to prevent this, YOU MUST run the rvm script from within your `.bash_profile`. Below is a fixed path and script for your .bash_profile:

export PATH=/opt/local/bin:/opt/local/sbin:$HOME/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

Depending on the installation of your system, your path could contain a bunch of stuff. Don’t worry what it looks like, just make sure you add `$HOME/bin` to the end. Now close and reopen the Terminal. Next follow the instructions here to link the `subl` executable to by issuing the following command in the Terminal window:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

After that, you should be able to open SublimeText from a command prompt by doing `subl .`

subl .

Now when you run RubyTests it will be able to find rspec and work.

Lesson 10

The css for the micropost is located at Listing 10.24.

CFWheels and implementing a Service Layer

Posted in Uncategorized by rip747 on June 2, 2012

A couple of weeks ago Doug Boude (rhymes with loud) authored a post about providing a service layer in CFWheels. I’m not going to go into what a service layer is or the use of it. If you want to know that, check out his post here.

Personally I never saw I use for this before. In keeping with the MVC tradition of doing thing, I always felt that these `services` could live in the model layer. However I absolutely love when people make me fall on my sword and I can clearly say that a service layer is definitely something that is needed in CFWheels. I still wouldn’t go so far as using it with a DI like WireBox, but who knows if I’ll change my mind about that later in life as well.

Following Doug’s post, I was able to implement a service layer with ease. The issue I had with his approach though was that it made testing very awkward. Having the initialization of the service layer living in the controller init method, made it a little hard to test, not impossible mind you, but a little harder then it should have been.

After giving it some thought, I figured out a way to not only make it so that the services initialized when CFWheels booted, but also was able to make the service() method global so that you can easily test against it.

If you take a look at this gist I created you’ll see the changes I made. Basically all I did was move his initServices() method into the events/onapplicationstart.cfm file and move the service() method into the events/functions.cfm file. The big change I made though was to the initServices() method so that it would automatically initialize any new services that you add to the services directory.

By putting these methods into their new homes, the services are loading once when CFWheels boots as apposed to every time a controller is created and also you’re able to access the service() method from anywhere in your application which make it easy to call in tests.

Tagged with:

rvm install 1.9.3 fails: truncated tar archive

Posted in Uncategorized by rip747 on June 2, 2012

installing ruby 1.9.3 via rvm and it fails with `trucated tar archive` which you can see by going doing `more ~/.rvm/log/ruby-1.9.3-p194/extract.log`.

the simpliest way to fix this is to uninstall rvm and reinstall. you can uninstall rvm by doing `rvm implode` and install by following the installation instructions: https://rvm.io/rvm/install/

xcode 3.2.6 installation failed: CSSMERR_TP_CERT_EXPIRED

Posted in Uncategorized by rip747 on June 2, 2012

when installing xcode 3.2.6 on OS X 10.6.6 (Hazard) the installation might fail with the following error when viewing the /var/log/install.log CSSMERR_TP_CERT_EXPIRED. this is because obviously the certificate has expired and xcode can’t verify that the certificate is valid.

a quick and easy solution is to change your system data to 1/1/2012 and then perform the install.

http://stackoverflow.com/questions/9953835/xcode-3-2-3-installation-failed-on-mac-10-6-3

Note to self: vertical align images in floated list in IE6

Posted in Uncategorized by rip747 on January 6, 2011

I’m constantly forgetting this, though hopefully i won’t need this after this year 😛

In order to get IE6 to respect vertical-align:middle on floated list element, use the underscore hack to add a font-size with the same pixel value as the line height.

NOTE: in this example the images are 60px height.

li {
float: left;
margin-right: 5px;
line-height: 60px;
_font-size:60px;
}

li img {
vertical-align:middle;
}