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.
Related
I am writing a Chrome Extension which utilizes the Chrome Debugger protocol.
To do this, I call chrome.debugger.attach(Debuggee d, string requiredVersion) (documentation).
My question is about the requiredVersion param. According to the docs, you specify a version number of the protocol to use, and this link contains possible versions you can use. So on that link, you see possible versions: 1.2, 1.3, and tip-of-tree.
I can pass in "1.2" or "1.3" and the call to chrome.debugger.attach succeeds, however does anyone know what string I pass in to use the tip-of-tree version? It doesn't correspond to any numbered version. Or is using tip-of-tree not possible?
I have an application that uses MapBox's API to stylize the underlying map which uses Google Places. This all worked perfectly fine when running in IOS 7+, but when I try testing this in IOS 8, it immediately crashes with the following error message:
Terminating app due to uncaught exception NSInternalInconsistencyException, reason: 'The layout constraints still need update after sending -updateConstraints to MapView at {0,0}-{320x444}.
RMMapView or one of its superclasses may have overridden -updateConstraints without calling super. Or, something may have dirtied layout constraints in the middle of updating them. Both are programming errors.'
I have been looking around the Web and Stack for a while but have been unable to find anything helpful unfortunately. Any suggestions?
I deleted all Mapbox framework / headers / lib from my project and reinstalled the latest (1.4.1) mapbox static library (libMapbox.a) and the Headers, and everything was ok after that without changing a line of my code.
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 :).
I have created a safari plugin using NPAPI and I want to add a NSView in my plug-in.
When I try to get NPWindow throw function NPP_SetWindow(NPP instance, NPWindow* window), the second parameter is nil.
I think my plug-in is windowless, but i don't know how to create a windowed.
NPAPI on Mac does not support NSView as a windowing mode. There are two supported modes:
CoreAnimation (or InvalidatingCoreAnimation on Chrome and Firefox)
CoreGraphics
There used to be a QuickDraw mode, but that's deprecated.
For more information, see Stuart Morgan's excellent blog post on the subject.
It is possible to make a NSView render to a CoreGraphics context but you'd have to proxy all of the events and it is far from perfect.
EDIT: To further explain the answer to your question, the reason that the window parameter is NULL (it's a C api, not Obj C, so it's NULL, not nil... despite them being the same thing =]) is because in the Cocoa Event Model you get a CGContextRef as part of the draw event which is only valid during the context of that event.
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".