When I run cucumber scenarios under PhantomJS I get
Capybara::ElementNotFound: Unable to find css ".given_class"
exceptions in random places
it looks like driver does not wait for element appearance
I'm using:
Ruby 2.0
Cucumber 1.3.6
Capybara 2.1.0
Selenium-webdriver 2.35.1
PhantomJS 1.9.1
Capybara, particularly with PhantomJS will load a page really quickly, and perform checks for elements. As such, some elements may not have loaded and tests fail. By default capybara has a wait time of 2, which you can increase. Maybe try:
Capybara.default_wait_time = 5
like they suggest in the docs here.
You can also add a Sleep(1) in your step definition, but that is considered bad form.
If that doesn't do it for you, try specifying where on the page the element should be found.
For example:
Then /^I should see "(.*?)" on the dashboard$/ do |your_element|
within("#your") do
expect(page).to have_content(your_element)
end
end
Check the Capybara.automatic_reload parameter.
By default it is true and capybara floods server with requests every 50 ms, if it does not see what it wants :).
Related
I'm trying to get chrome's V8 (d8) x64.release version to use the V8 support tools in GDB, specifically for the job and telescope commands (predominantly the former).
My x64.debug version has this implemented and works, but even after building the x64.release version in a similar manner I still cannot get these commands to work in the x64.release version. The output is always as:
gef⤠job 0xd98082f7b51
No symbol "_v8_internal_Print_Object" in current context.
I have set args.gn before, and after building via ninja -C to include v8_enable_object_print = true in my args.gn:
is_debug = false
target_cpu = "x64"
use_goma = false
v8_enable_object_print = true
v8_enable_disassembler = true
I also have my ~/.gdbinit containing:
source ~/Desktop/tools/v8/tools/gdbinit
source ~/Desktop/tools/v8/tools/gdb-v8-support.py
See: https://chromium.googlesource.com/v8/v8/+/refs/heads/main/tools/gdbinit (for the support tool I'm trying to build V8 with).
How can I get my /v8/out.gn/x64.release/d8 to run with compatibility of the job command?
Am I missing something here? If so your help would be very helpful.
EDIT Alternatively how can I disable all x64.debug V8 DCHECKS?
Thanks all, appreciate your time here.
How can I get my /v8/out.gn/x64.release/d8 to run with compatibility of the job command?
I'm not sure. Try adding symbol_level = 1 (or even symbol_level = 2) to your args.gn. That definitely helps with stack traces, and might also be the thing that lets GDB find the _v8_internal_Print_Object function by name.
Alternatively how can I disable all x64.debug V8 DCHECKS?
There is no flag to disable them, but you can edit the source to make them do nothing. See src/base/logging.h.
So now I've got cucumber/capybara/selenium hitting a google app script, which is great, but for some reason I can't seem to check for text in the body of the page in the way I expect. In the debugger I can grab the page object, which I can in the browser has the expected text. Scanning the html directly shows the text appearing twice, and yet page.has_text? appears false:
(rdb:1) p page.html.scan(/Introduction Video/)
["Introduction Video", "Introduction Video"]
(rdb:1) p page.has_text? 'Introduction Video'
false
an alternate scan gives more information on the text surrounding:
(rdb:1) p page.html.scan(/.{10}Introduction Video.{10}/)
["" Introduction Video\\u003C\\/a&", "lank\\\">Introduction Video\\u003C\\/a&"]
which makes me wonder if this is an encoding issue. I want to look at exactly what the has_text? method does, so I look at the docs:
http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers#has_text%3F-instance_method
But I can't get the additional parameter to be accepted:
(rdb:1) p page.has_text? :all, "Introduction Video"
ArgumentError Exception: wrong number of arguments (2 for 1)
which makes me wonder if the code I am running is the same as in the docs - and brings me back to my usual Ruby bugbear of not being sure where to go to find the open source code I am relying on ...
Anyway, all the code I'm using is here:
https://github.com/tansaku/GoogleAppScriptBDD
Any help very much appreciated.
In Capybara 2.0 has_text? has only one parameter - content.
type parameter of has_text? (with possible values :all and :visible) appeared in version 2.1 which is currently in beta.
However, Capybara 2.1.0.beta1 is stable and doesn't have any known regression bugs. Currently it's supported only by built-in Selenium and Racktest drivers. At the moment of writing available gem versions of Capybara-Webkit, Poltergeist and Terminus don't support Capybara 2.1.
I use 2.1.0.beta1 so I can recommend you to use it if you use built-in selenium or racktest drivers.
How do you interpret this error?
Uncaught Error: Load timeout for modules:
domReady!_unnormalized2,domReady!_unnormalized3,domReady!
I'm using requirejs 2.1.2 and domReady 2.0.1.
It doesn't happen always, and apparently only in Chrome (in IE and firefox works fine).
I incremented the default load time with:
require.config({ waitSeconds: 90 });
but it keeps failing.
Any Ideas? I would appreciate any help
There is a standard amount of time that RequireJS will wait for a given require() call to complete; it allows some time for the relevant files to download. When using domReady!, the require call is forced to wait until the DOM is ready, which could be a longer period of time than require is willing to wait - resulting in the error you mention.
Ideally the DOM would not take so long to be ready, as that itself is an issue for the user experience, but in the case that it does, I believe we will have to avoid the domReady! dependency.
I had a non-OSGi application. To convert it to OSGi, I first bundled it up and gave it a simple BundleActivator. The activator's start() started up a thread of what used to be the main() of my app (and is now a Runnable), and remembered that thread. The activator's stop() interrupted that thread, and waited for it to end (via join()), then returned. This all seemed to be working fine.
As a next step in the OSGiification process, I am now trying to use OSGi configuration management instead of the Properties-based configuration that the application used to use. So I am adding in a ManagedService in addition to the Activator.
But it's no longer clear to me how I am supposed to start and stop my application; examples that I've seen are only serving to confuse me. Specifically, here:
http://felix.apache.org/site/apache-felix-config-admin.html
They no longer seem to do any real starting of the application in BundleActivator.start(). Instead, they just register a ManagedService to receive configuration. So I'm guessing maybe I start up the app's main thread when I receive configuration, in the ManagedService? They don't show it - the ManagedService's updated() just has vague comments saying to "apply configuration from config admin" when it is passed a non-null Dictionary.
So then I look here:
http://blog.osgi.org/2010/06/how-to-use-config-admin.html
In there, it seems like maybe they're doing what I guessed. They seem to have moved the actual app from BundleActivator to ManagedService, and are dealing with starting it when updated() receives non-null configuration, stopping it first if it's already started.
But now what about when the BundleActivator's stop() gets called?
Back on the first example page that I mentioned above, they unregister the ManagedService. On the second example page, they don't show what they do.
So I'm guessing maybe unregistering the ManagedService will cause null configuration to be sent to ManagedService.updated(), at which point I can interrupte the app thread, wait for it to end, and then return?
I suspect that I'm thoroughly incorrect, but I don't know what the "real" way to do this is. Thanks in advance for any help.
BundleActivator (BA) and ManagedService (MS) are callbacks to your bundle. BundleActivator is for the active state of your bundle. BA.start is when you bundle is being started and BA.stop is when it is being stopped. MS is called to provide your bundle a configuration, if there is one, or notify you there is no configuration.
So in BA.start, you register your MS service and return. When MS is called (on some other thread), you will either receive your configuration or be told there is no configuration and you can act accordingly (start app, etc.)
Your MS can also be called at anytime to advice of the modification or deletion of your configuration and you should act accordingly (i.e. adjust your app behavior).
When you are called at BA.stop, you need to stop your app. You can unregister the MS or let the framework do it for you as part of normal bundle stop processing.
Is there an API to determine whether a given job is currently running or not?
Ideally, I'd also like to be able to determine its estimated % complete and get the details of the SVN revision number and commit comment too!
EDIT:
I found the answer. http://host/job/project/lastBuild/api/ has almost all of what I need in it somewhere! If you kick off a manual build, it won't tell you the SCM changesets, but that makes sense. It does still tell you the latest SCM revision though, so that's good. All in all, good enough for my purposes right now.
As gareth_bowles and Sagar said, using the Jenkins API is the way to know.
If you put the depth to 1, you will see what you're looking for:
http://host/job/project/lastBuild/api/xml?depth=1
You will see there's a <building> tag to tell if that build is running
...
<build>
<action>
<cause>
<shortDescription>Started by user Zageyiff</shortDescription>
<userId>Zageyiff</userId>
<userName>Zageyiff</userName>
</cause>
</action>
<building>true</building>
<duration>0</duration>
<estimatedDuration>-1</estimatedDuration>
<fullDisplayName>Project #12</fullDisplayName>
<id>2012-08-24_08-58-45</id>
<keepLog>false</keepLog>
<number>12</number>
<timestamp>123456789</timestamp>
<url>
http://host/job/project/12
</url>
<builtOn>master</builtOn>
<changeSet/>
<mavenVersionUsed>3.0.3</mavenVersionUsed>
</build>
...
I'm using the Groovy plug-in, and run the following snippet as system:
import hudson.model.*
def version = build.buildVariableResolver.resolve("VERSION")
println "VERSION=$version"
def nextJobName = 'MY_NEXT_JOB'
def nextJob = Hudson.instance.getItem(nextJobName)
def running = nextJob.lastBuild.building
if (running) {
println "${nextJobName} is already running. Not launching"
} else {
println "${nextJobName} is not running. Launching..."
def params = [
new StringParameterValue('VERSION', version)
]
nextJob.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
}
It works like a charm.
If you go to your job's page, and add "api" to the end of the URL, you'll get information on using the API.
http://yourjenkins/job/job_name/api
More information on using the Jenkins API:
https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
If you're comfortable with digging through the Jenkins Java API, you could write a system Groovy script to get this data. The Job class is the place to start.
As stated on the /api page of your build (chapter "Accessing Progressive Console Output"), you can poll the console output with a GET request by calling <url-to-job>/lastBuild/logText/progressiveText. To quote the API doc:
If the response also contains the X-More-Data: true header, the server is indicating that the build is in progress
And there you go. You can test this behaviour by simply calling the respective URL in your browser and then inspecting the response headers with your browser's developer tools (usually accessed by pressing F12). In Firefox, the respective tab is called "network analysis" (assuming my translation is correct, my browser is not set to English). In Chrome, navigate to the "Network" tab.
This answer is based on Jenkins version 2.176.3.
It is also possible to look at the color attribute. I know it is not the wanted way. But maybe someone can make use of it.
get the overview xml via "/job/api/xml" and then check the color attribute for "anim".