Minitest-Capybara: find "a" - click "a" - unable to find link or button - capybara-webkit

Is it possible that if I write in my integration test:
all("a")[0]
the test goes well but when writing:
click_on(all("a")[0])
I get the error message "unable to find link or button"?
The has
href="javascript:void(0)"

The element return by all("a")[0] have a .click function.
all("a")[0].click
Or instead find by the name
all("#name_of_link").click

Related

returning error message to front end Scala Play

I need to send an error status to the front end using Scala play. Ok is to say all is ok but which one is for error? Can this be done from any Scala method I created?
thanks
It can be done from any method, you just need to use correspondent Result. For the general server error it is InternalServerErrorlike
def index = Action {
InternalServerError("Some error happens")
}
You can find more results here: https://playframework.com/documentation/2.6.7/api/scala/index.html#play.api.mvc.Results
The examples are:
InsufficientStorage //507
Locked //423
You can also send your own state as simple as
new Status(500) //aka InternalServerError

Poltergeist-phantomjs - switching to the new popped up window

Test env: Capybara,poltergeist, phantomjs.
A new window opens up when I click a link in my test case. I was able to switch to the new window and verify text using selenium driver. However, I am unable to switch to the new window with poltergeist. I tried the following method to switch to the new window and none of them worked.
I wanted to see if a new browser is getting open at all and looks like it is.
main = page.driver.browser.window_handles.first
puts main (gives 0)
popup = page.driver.browser.window_handles.last
puts popup (gives 1)
1. within_window(->{ page.title == '2015-11-5.pdf' }) { assert_text(facility_name) }
2. page.switch_to_window(window=popup)
3. page.switch_to_window(page.driver.browser.window_handles.last)
4. page.driver.browser.switch_to().window(page.driver.browser.window_handles.last)
Could someone provide any inputs here? Thanks!
I used the following and the popup is getting generated and the control switches to it.
page.switch_to_window(page.window_opened_by{click_link('Generate Report')})
The new window has a pdf embedded in it.I was able to read and verify the contents of the document when I use selenium driver. With poltergeist, I am unable to read the pdf. Could you give me some pointers on how to proceed?
Capybara has a number of cross driver methods for dealing with this without having to go to driver specific methods.
popup = page.window_opened_by {
click_link('whatever link opens the new window')
}
within_window(popup) do
# perform actions in the new window
end

How to get global error message?

I use a custom form validation in a controller:
verifying ("URL is already exist. Please choose another one.",
fields => models.DAUser.IfUrlValid(fields.email,fields.url))
In a view, I try to get the global error message by this:
#for(error <- data.globalErrors) {
<p>#error.message</p>
}
But what I get is:
FormError(,URL is already exist. Please choose another one.,WrappedArray())
How to just get the message ("URL is already exist. Please choose another one.")?
Thanks.

Zend Framework - ZFDebug - Log - Log Custom Errors

When using ZFDebug, is it possible to add custom messages to the 'Log' tab?
So you could use something like:
$this->log('Error: Couldn't find the user');
Has anyone managed to achieve this?
I have never used ZFDebug before and wasn't aware of it. Your post piqued my interest, so I installed it and have been trying to achieve what you want to do. I will probably add it to my dev toolbox as I use ZF a lot.
You can achieve what you want by using the mark() method of ZFDebug_Controller_Plugin_Debug_Plugin_Log which takes two arguments. The first is the message you want to send and the second is a boolean which, when set to true (default is false), will send your message to the 'log' tab.
The following code worked for me:-
$debug = Zend_Controller_Front::getInstance()
->getPlugin('ZFDebug_Controller_Plugin_Debug');
$logger = $debug->getPlugin('log');
$logger->mark('Logging a message now', true);
Or to use your example (with the syntax error fixed :) )
$logger->mark("Error: Couldn't find the user", true);
As you can see this produced the desired output:-
Not quite as simple as you wanted, I know, but it's close and you could always wrap it in a function.

TinyMCE bug - # symbol in link URL makes http://mce_host appear

Have someone a resolution for that annoying problem?
Try this:
Open the file /sites/all/modules/tinymce/tinymce.module
Find the following function:
function tinymce_config($profile) {
...
}
Within that function, find the following line and remove it or comment it out:
$init['entity_encoding'] = 'raw';