How can Watir-WebDriver find a class which was updated through JS? - watir-webdriver

What I'm trying to do is click a 'Next' button on an image slider and verify that it brings me to the next image.
The pagination pips have class "btn dot icon". There is an EventListener which gives the pip of the currently selected slide the class "btn dot icon selected". I can verify this in irb:
irb(main):091:0> #b.span(:class, 'btn dot icon selected').text
=> "Page 0"
irb(main):092:0> #b.span(:text => 'Next', :index => 1).click
=> []
irb(main):093:0> #b.span(:class, 'btn dot icon selected').text
=> "Page 1"
However, running the same through Watir-WebDriver it returns "Page 0" throughout any clicks of 'Next'. Adding an implicit wait does not make a difference.
What might be the issue here?
Note: The 'Next' button matcher looks for the second occurrence (:index => 1) because there is another slider above the one I'm interested in, but this slider does not have the pagination pips (verified through #b.spans(:class => 'btn dot icon').size).
Ruby 1.9.3p545, Watir-WebDriver 0.6.11, Selenium-WebDriver 2.44.0, Firefox 33.1

Turned out to be a simpler solution than I was expecting. Solved it by changing
#b.span(:text => 'Next', :index => 1).click
to
#b.span(:text => 'Next', :index => 1).fire_event("onclick")
Watir-WebDriver was executing a click on the span successfully, but it looks like it can't fire the JavaScript click event on that span. Manually making it fire the JavaScript event works.

Related

Flex Relate field value is blank in List of Sub Panel

There are two modules: Customer & Top Transaction
Relationship between them: 1(Customer):Many(Top Transaction)
There is one 'Flex Relate' field in Top Transaction module.
Now I want to display that 'Flex Relate' value on sub panel list of Top Transaction module.
For that I did changes from studio->Customer->Sub-Panel->Top Transaction.
On Customer detail page under Top Transaction sub panel it's showing only header of 'Flex Relate' field & no value(values are blank).
Does anyone know solution to this?
I'm using 6.5 community edition.
Please check this link for flex relate Flex relate
Try to use relate field instead of flex related i think it will solve your problem .
I know, this is the old question, but here is the solution I have found.
Add these 2 fields in the subpanel metadata and this would show the parent/flex field properly.
However there is still an issue in that, here the target module is fixed. I will update this as soon as I find any solution to it.
Untill that, I think this is achievable in process_record hook. But, I am looking for some generic solution.
'parent_type' =>
array(
'usage' => 'query_only',
),
'parent_name' =>
array(
'width' => '10%',
'vname' => 'LBL_FLEX_RELATE',
'id' => 'parent_id',
'link' => true,
'widget_class' => 'SubPanelDetailViewLink',
'target_module' => 'AOS_Invoices',
'target_record_key' => 'parent_id',
'default' => false,
),

SuiteCRM increase autocomplete time in EditView

I'm looking at a request from our customer to either lengthen the autofill or just remove it all together when adding an organisation in EditView.
e.g: https://demo.suiteondemand.com/index.php?module=Opportunities&action=EditView&return_module=Opportunities&return_action=DetailView
If you start typing into "Account Name" box 'A' it'll show all the Organisations starting with A but also it'll autofill the first result into the input box.
Is there a way to stop that autofill of the input box from happening or delay it?
Thanks
Edit: changed title to SuiteCRM
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Quicksearch/
I used the Metadata example, and it worked.
[Edit]
To expand on the answer. If you want to remove autofill from any of the boxes you need to add the 'sqsNoAutofill' to achieve this you can do the following:
In a modules editviewdefs.php (e.g. modules/(module)/metadata/editviewdefs.php) locate the name of the input you wish to change e.g:
array (
'name' => 'assigned_user_name',
'label' => 'LBL_ASSIGNED_TO',
),
then add the following:
array (
'name' => 'assigned_user_name',
'label' => 'LBL_ASSIGNED_TO',
'displayParams' => array (
'class' => 'sqsEnabled sqsNoAutofill'
)
),
This will stop an input box with a quicksearch drop down from autofilling.
You can also make the change to the SugarField for Parent
include/SugarFields/Fields/Parent/EditView.tpl (line 51):
<input type="text" .... class="sqsEnabled sqsNoAutofill" .....>
I hope that helps someone else.

How to click a button in nested div?

I am new to Watir,and I met trouble when I tried to click the "Add" button in a website. Here is source code:
<div class="page_and_btn">
<div>
<a href="javascript:addUser();" class="myBtn">
<em>Add</em></a>
</div>
So far,I tried any way I can find,but just got an exception:unable to locate element.
Here are the code I have tried:
ie.div(:class,"myBtn").click
ie.link(:class,"myBtn").click
ie.link(:text,"Add").click
ie.button(:text,"Add").click
Please tell me what should I do?
You can write short selector
ie.em(:text => 'Add').click
but better will be write long
ie.div(:class => 'page_and_btn').em(:text => 'Add').click
very useful method flash
what show element on page
ie.div(:class => 'page_and_btn').em(:text => 'Add').flash
ie.link(:class,'myBtn').click works fine for me.Still you are not able to proceed further,try below code.
ie.div(:class,'page_and_btn').link(:class,'myBtn').em(:text,'Add').click

CakePHP 2.3.1 deactivate form validation in certain views

The Cookbook introduces for version 2.3 the possibility to deactivate the forced valiadation for forms. Or at least I understood it like that:
Quote: from http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html
" New in version 2.3.
Since 2.3 the HTML5 required attribute will also be added to the input
based on validation rules. You can explicitly set required key in
options array to override it for a field. To skip browser validation
triggering for the whole form you can set option 'formnovalidate' =>
true for the input button you generate using FormHelper::submit() or
set 'novalidate' => true in options for FormHelper::create()."
In my case I have a search from for this model and of course the user does not need to fill in all mandatory fields like for adding a dataset. So I want to deactivate the validation for my search form.
I tried all three variations and see no results: Still the mandatory fields for create are mandatory in my search form.
Those attempts I made:
first try:
echo $this->Form->create('Partner', array('action' => 'search', 'novalidate' => true));
second try:
echo $this->Form->input('name',
array('required' => false, 'value' => $this->Session->read('Searchparameter.name'))
);
third try:
$this->Form->submit('Submit', array('formnovalidate' => true));
echo $this->Form->end();
variation:
echo $this->Form->end(__('Submit'), array('formnovalidate' => true));
What did I understand wrong? btw: I did deactivate caching, so that should not be the problem.
Of course I could still use the old workaround for this validation, but when 2.3 is offering this option, I would gladly use it.
Calamity Jane
So I guess I found the problem and at least got one varation working:
What I am using now is:
echo $this->Form->create('Partner', array('action' => 'search', 'novalidate' => true));
I guess what I expected was that the fields wouldn't be marked with the fat label and the asterisk. Those are still there, but regardless you don't have to fill them in anymore. And the times I tested with really submittig the form I guess I had one of the 99 varations, which was really wrong.
If that makes me happy is mine to decide, but obviously I can switch off the HTML5 validation by that.
If I would want to have the labels not bold & asterisk, is there an option, too?
Calamity Jane
The solution is actually a lot simpler. If you would like to disable validation in specific views you actually only have to refer to a non-existing model when you create the form. You could for example do something like
echo $this->Form->create('PartnerSearch');
In your controller you can access the form fields through:
$this->request->data["PartnerSearch"]["field"]
instead of the usual way:
$this->request->data["Partner"]["field"]
For me, to skip the browser validation, yes, array('novalidate' => true) does work.
<?php echo $this->Form->create('MyModelName', array('novalidate' => true)); ?>
To have the label not bold & asterisk,
<?php echo $this->Form->input('myinput', array('required' => false));
In my case I used button for submitting the form. This allowed me more flexibility. In that case I used then property 'formnovalidate' pass in the array of options for the button. The form would look something like the following:
<?php
echo $this->Form->create('yourCtrllerName',array('action'=>'actionInYourCtrller'));
echo $this->Form->input('your_field_pass',array('label'=>'pass','type'=>'password'));
.... other Form fields .....
echo $this->Form->button('Button Caption',
array('type'=>'submit',
'name'=>'keyInsideTheDataArrayForButtonData',
'formnovalidate' => true,
'value'=>'valueOfTheAboveKeyInTheDataArray',
'style'=>'<style you want to apply to button>',
... other options if needed...
)
);
echo $this->Form->end();

Zend_Form - prefix text using decorator

I want to prefix the form title within the form tags, but above the form elements.
<form>
<h3>Login Form</h3>
<!-- form elements -->
</form>
I do not want to use a view script.
I thought of using the Description decorator, but that appears to be only available to the elements.
How do I set an arbitrary description for a form, and position it (either append / prepend) within the form tags? I have a feeling I need to play with the HtmlTag decorator but I've played with it and can't get the right results.
Typical. Ask a question, work out the solution.
$form->setDecorators(array(
array(
'Description',
array(
'tag' => 'div',
'class' =>'title'
)
),
'FormElements',
'Form'
))
->setDescription('Enter Login Credentials:');
Depending where you place the description decorator will determine where in the form tags it displays, i.e. place above 'FormElements' to display above the elements; place below 'FormElements' to display the description below the elements; place below the 'Form' decorator to display after the form tags.