how to make phantomjs gem not to ignore browser validations while testing - capybara

I use phantomjs gem to run my feature tests.
But when I ask test to leave empty required fields and then to press Submit button - it runs into controller for some reason.
Of course, when I do it manually in browser - I get a 'field can not be empty' without server request.
How can I fix it and make phantom js to respect a client validators?
ActiveRecord::RecordInvalid:
Validation failed: Email can't be blank, Password can't be blank, First name can't be blank, Last name can't be blank, Phone number can't be blank, Access parameter should be an admin for first company employee
# ./app/controllers/employees/registrations_controller.rb:25:in `create'

PhantomJS hasn’t been updated in years and is currently equivalent to an 8 year old version of Safari. That means it most likely doesn’t support HTML form validation and a lot of other JS/CSS technologies used by modern sites/apps. You need to move to using selenium with headless Chrome or one of the direct to chrome via CDP (https://github.com/twalpole/apparition , etc) drivers for your testing

Related

Kentico MVC - PageBuilder Error on external Staging site

Am using Kentico MVC v12 Service Pack.
Have enabled Preview feature and PageBuilder in Application_Start.
When running from localhost, can successfully edit relevant pages using PageBuilder as required.
However, when ran from a staging site, which is a clone of the localhost version, I am getting an error in the Site settings when I try to add a Presentation Url (I am definitely adding in a valid format with the starting "https://" included), which is required for the PageBuilder to be used in the Pages application, where I see this error:
An unexpected error occurred, see event log for more details. Event source: PageEdit, Event code PreviewLinkGeneration
Any assistance would be much appreciated.
Thanks.
Sites error
That error is basically only looking at the string of the URL (almost like a simple validation). Are you sure there is no whitespace before the value you entered in? I can re-create your issue if I type in a space character before the URL.
You can also try clearing the field and saving the form. Then re-enter a value.
If it is still not working, try re-signing all your macros in the system as I have seen the regular expression validation rules have issues if macros aren't working. Which is really what this check is:

Using Orbeon Forms "List Forms Attachments" API

We have the requirement to fetch an attachment to an Orbeon form from a simple automation script. We found the "List Forms Attachments" API (https://doc.orbeon.com/form-runner/api/persistence/list-form-data-attachments.html) and are trying to call it using a simple "curl" script that runs on the same host as the Orbeon Tomcat instance:
curl -v "http://localhost:8080/orbeon/fr/service/$app/$form/attachments?document=$docid"
This returns an HTTP 403 (Forbidden), and even after reading whatever doc we can find on Orbeon security, we're still scratching our heads over how to configure Orbeon. Is there a simple configuration example showing an Orbeon configuration that would allow the API to be called from a local script like ours? We are running Orbeon CE 2017.1.
If getting this API to work is an ordeal, the other option we'd consider would be a database solution. We have Orbeon running on a MySQL persistence layer, and the same script we're using also has access to this database. Is there an easy way to take a submitted form's XML and fetch the attachment for a given form field?
We see in the submitted form's XML that the attachment tag looks like this:
<File1 filename="Original Filename.doc" mediatype="application/msword" size="14236">
file:/tmp/tomcat7-tomcat7-tmp/xforms_upload_7266596219758922423.tmp?filename=Original+Filename+doc&mediatype=application%2Fmsword&size=14236&mac=fc2febb1227e93643a048fbb02abc16bba346531
</File1>
When we scan the orbeon_form_data_attach database table, we see a row with the file content we expect, but the file_name column doesn't match the file information in the form's XML above...in this example, the file_name on the database is 1af8cd16367470362e13f77e679c0ae590e1f4a5.bin. Some of our forms have multiple attachments, and there doesn't seem to be a direct way to go from the form XML to the file_name in the database table.
Either of these solutions would be fine for us - we just need a way to get the attachments for a form from a simple script.
For reference, the relevant documentation is Authorization of Pages and Services.
You can, although this is not to be done for production but only testing and development, open all services without authentication. See this section. Otherwise, you need to setup an authorization service.

PHPlist urls in email body changed to clicktrack urls

I have clicktrack turned off, however text only messages with url links in them are having the url's changed to a clicktrack url's. That is they point back to "mywebsite.com" and not the intended url link.
I have searched google and found people (this year 2014) having similar problems but no answers.
All the clicktrack settings in the config files are correct "off" (does not seem that complicated)
changing them to html ref just leaves me with the href label which is not clickable (might be a clue but not sure), and I actually want to send text email not html.
Has anyone else had this problem, or any ideas on solutions?
I added the following settings to try to solve and it seems it works
# Usertrack
# Usertrack is used to track views or opens of campaigns. This only works in HTML messages
# as it relies on a little image being pulled from the phpList system to update the database
# To add it to your campaigns, you need to add [USERTRACK] somewhere.
# From version 3 onwards, this is automatically done with the following setting. If you do not
# want it, you can switch it off here, by uncommenting the next line
define('ALWAYS_ADD_USERTRACK',0);
# Click tracking
# If you set this to 1, all links in your emails will be converted to links that
# go via phpList. This will make sure that clicks are tracked. This is experimental and
# all your findings when using this feature should be reported to mantis
# for now it's off by default until we think it works correctly
define('CLICKTRACK',0);

Is there a reason that Selenium tests would act differently on Ubuntu vs Mac OSX?

I am working on a project with a partner and we both are using different Operating Systems. All of our files, including the Gemfileare under version control. Previously, I had written tests in Rspec with Capybara and selenium-webdriver. These tests opened Firefox and performed simple actions, passed, and closed the browser.
A few unrelated changes to the layout concerning flash[:success] and now, with both of us updated to the HEAD, the tests pass on my machine, but fail on his.
His browser is not loading the modal box from the before block click_link "Edit" therefore when the test tries to fill in a form, the fields are still hidden and not accessible.
I attempted to wait for the box, thinking it may be filling in the fields too soon :
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { page.driver.browser.find_element(:css, "div#edit_news_container").displayed? == true }
Instead I get a timeout, and the tests still fail.
However, they work beautifully on my machine... what's going on here?
In light of the layout changes, it's likely you're having a browser issue rather than an operating system issue. Are the two of you using the same version of Firefox? If not, changing his version to yours may allow him to load the modal again.

Grails/Spring Security: Unable to login with a newly created user

I have just started using grails and installed the spring-security and spring-security-ui plugins. I am following the tutorial given here. The application starts with one bootstrapped user me with ROLE_ADMIN permission.
With the UI override scripts I was able to get the register functionality up and running and it works all right. Now, I have installed the User Management scripts (grails s2ui-override user) to try adding, editing, removing users.
A new user gets created fine, I have checked this against the HSQLDB instance. However, if I now log-out from the application and try to login with the newly created user the application tells me that it is unable to find a user with the provided username and password.
I haven't modified the default logout handling so am using /j_spring_security_logout which as the documentation says invalidates the session.
Is this a know issue? If so how can I get around this or if not how can I debug this issue?
EDIT:
This issue is also persisting without the UI addition. Register as a new user. Once you finish e-mail verification you are auto-logged in to the site. Now logout and try to login in back again. It gives the same error.
FINAL EDIT:
The UI plugin comes with the RegisterController that still encodes the password. However, the newer domain classes that come with the core are also doing this and the recommended practice is that controllers shouldn't. I commented out a line that does the encoding and the login/logout works now at least for the basic scenario.
There is a warning on that tutorial
Earlier versions of the plugin didn't include password encryption logic in the domain class, but it makes the code a lot cleaner.
I am guessing security-ui plugin does not know about that change, and comparing unencrypted password with the encrypted one on the database.
l managed to fix my problem. The problem was double encryption. Under the spring security ui in the user controller on line 41 the password was being encrypted and then again by the domain class so on login it was comparing a double encrypted password and a single encrypted password. To solve the problem l just commented out line 41 in the user controller which was encrypting the password
EDIT: If you have trouble figuring out where one would go to edit the controller, you can find the source code of the downloaded plugins in your user home's
/.grails/version/projects/projectname/plugins
directory for editing (at least on Mac / Linux, dunno where you'd find it in windows).

Resources