Select multiple rows objects using Selenium in ruby - ruby

I’m trying to write an automated scripts where I need to select multiple objects. Here is what I tried:
#browser.action.key_down(:left_shift).perform
post_elements[0].click
post_elements[2].click
#browser.action.key_up(:left_shift).perform
it doesn’t work for me. Please advise, thanks!

I think you want to structure your code like this:
#browser.action.key_down(:left_shift)
.click(post_elements[0])
.click(post_elements[2])
.key_up(:left_shift).perform

Related

How can I change the execute order for Magmi plugins?

I'm working on importing (on a regular basis) about 6,000 items into Magento using Magmi. I've got nearly everything configured the way I need it, but I have one issue.
I need to concatenate 3 columns from my .csv file to create a "category_ids" column. I'm using the Value Replacer plugin with the following value:
{item.departmentid},{item.classid},{item.subclassid}
This works well, however I need to then map this field to another field using the Generic Mapper plugin. Both functions work individually, however I need the Value Replacer to run BEFORE the Generic Mapper. As best as I can tell, it appears the Generic Mapper runs first. Is there a way I can alter the execute order for these two plugins?
Thanks for the help!
Update for Dweeves:
Doh! I totally overlooked that section while trying to figure this out. Now that I've gone through it, I might need a little more help. Right now I've using just the Value Replacer plugin with the following settings:
Replaced attributes: category_ids
New value for category_ids:
{{ ValueRemapper::use_csv('/var/www/magmi/category_ids.csv')->map({item.departmentid},{item.classid},{item.subclassid}) }}
It doesn't seem to be working as I intended it to, but I'm a systems guy and not a PHP programmer. Any help?
2nd Edit
I got it working by using the Value Replacer function to first concatenate everything into a new "test" column, then using the Value Replacer Value Mapper function to create the category_ids column with the mapped values. Confusing, but it's working well.
You can use the ValueRemapper helper of Value Replacer plugin for this kind of purpose.
See Value Replacer Plugin Documentation (ValueRemapper helper section)
To answer your original question (how to define the order the plugins run in).
From my experience, the plugins are loaded in order of their plugin filename.
For example, if you look at magmi/plugins/base/itemprocessors/importlimiter, you will notice that the filename for the plugin is 01_importlimiter.php.
If you look in the genericmapper plugin folder, you'll notice the plugin filename to be 02_genericmapper.php.
With this being said, 01_importlimiter.php will execute before 02_genericmapper.php.

How to massive delete in php-activerecord where id NOT in list?

I'm running a CodeIgniter application with PHP-Activerecord installed and I need to do a massive delete. The PHP-AR library supports massive update and delete, but the function only takes the ids that you want to delete/update. I'm trying to do a massive delete where the ids are NOT in the list.
delete from table where id not in (1,2,3...,500)
Unfortunately, the PHP-Activerecord website is of no help, and their forums are so horribly built (no search... seriously?) that I'm truly stuck.
edit: Please note, CodeIgniter's built-in ORM is not the same as PHP-Activerecord. Just thought I'd clarify that.
A bit late but this may help someone else. In PHPActiveRecord, do it in this way:
$ids_to_delete = array(1,2,3);
YourModel::delete_all(array('conditions' => array('id NOT IN (?)', $ids_to_delete)));
Ref: http://www.phpactiverecord.org/docs/ActiveRecord/Model#methoddelete_all
SInce active record is actually build string query with function, you can use this method:
- make your list as string
- make this query : $this->db->where('id not in',$string)->delete('table')

Datamapper - best practices for pre-loading data

I'm writing a web app using Ruby/Sinatra and Datamapper. I have some tables that I want to preload data into. Is there a best practice for that? E.g. I have a table called references
id name url
-- ---- -------------------
1 AOL http://www.aol.com
2 Dell http://www.dell.com
I want to ensure that this data is always loaded when someone starts up the app for the first time and and ensure the IDs do not changes....
Thoughts?
There may be a gem out there to do this for you which I'm not aware of, and if there is, I'd love to hear about it. But, for my last project I simply had my import data in a yaml file and wrote a Ruby class that parsed that yaml file and used DataMapper to insert the data for me.
I then created a Rake task that allowed me to run this Ruby class.
Is this the sort of solution you might be after? If so, I can give you more info on it.

Sorting a view by dropdown

Hey, i've been looking around for a ajax dropdown sorter for my Views in Drupal.
Unfortunatly, i haven't found alot of usefull information about this subject.
Can anyone tell me if theres a solution already available or can help me started on a custom module by telling me which hooks i should use?
I had a similar issue. Unfortunately I wasn't able to sort the data from the database which is by far the best way. I was however able to take the data and sort it with PHP using a preprocessor function. Depending on the name of your view, setup a function similar to the following:
function templatename_preprocess_name_of__view(&$vars)
{
//Super sweet sorting code goes here
}
The name of your view needs to follow the name of the template file that it is driven by, if there isn't on you should create one. Make sure to change dashes to underscores in your function name. Hope this is helpful. If you find a way to do it from the DB I'm all ears because that would be super awesome.

Prototype Form.serialize(this) merging with another hash

I'm trying to merge a form hash with another hash using Prototype (1.6.0.3)
This doesn't pass any parameters to the server
Name
but this does
Name
Any ideas on how to fix this? I don't get any javascript errors.
Looks like this is an issue with the old version of the Prototype docs:
That's a documentation issue. Expected
output (from Form.serialize) is a
vanilla JS object, not a hash https://groups.google.com/group/prototype-core/browse_thread/thread/d686de54683b206c?pli=1
UPDATE
You can achieve what you want like this:
Name
This makes use of Object.extend:
Object.extend(Form.serialize(true), {order: 'descend_by_created_by'})

Resources