Your SlideShare is downloading. ×
0
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
High-level Web Testing
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

High-level Web Testing

5,622

Published on

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,622
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. High-level web testing Peter Sergeant Contractor @ NET-A-PORTER
  • 2.  
  • 3.  
  • 4.
    • # $mech is a WWW::Mechanize subclass object
    • $mech ->get( '/Fulfilment/Putaway?process_group=844284' );
    • print Dumper $mech ->as_data();
    • # Page contents as data
    • $VAR1 = {
    • 'metadata' => {
    • 'delivery_number' => '615019' ,
    • 'process_group_id' => '844284' ,
    • 'page_type' => 'Surplus' ,
    • 'Designer' => 'Rows' ,
    • 'Description' => 'New Description' ,
    • 'Colour' => 'Black' ,
    • 'Sales Channel' => 'MRPORTER.COM'
    • },
    • 'item_list' => [
    • {
    • 'Size' => 'None/Unknown' ,
    • 'SKU' => '2106034-001'
    • },
    • {
    • 'Size' => 'None/Unknown' ,
    • 'SKU' => '2106034-005'
    • }
    • ]
    • };
  • 5.
    • 'Fulfilment/PackingException/ViewContainer' => {
    • auto_match => qr!^/Fulfilment/PackingException/ViewContainer?container_id=Mw+ $! ,
    • specification => {
    • orphaned_items => {
    • location => 'id("orphaned_items")' ,
    • transform => 'parse_table' ,
    • optional => 1 ,
    • },
    • shipment_items => {
    • location => 'id("shipment_items")' ,
    • transform => 'parse_table' ,
    • optional => 1 ,
    • },
    • cancelled_items => {
    • location => 'id("cancelled_items")' ,
    • transform => 'parse_table' ,
    • optional => 1 ,
    • },
    • }
    • },
  • 6.
    • 'Fulfilment/Packing/EmptyTote' => {
    • auto_match => qr!^/Fulfilment/Packing/EmptyTote!,
    • specification => {
    • totes => {
    • location => 'id("totes")' ,
    • transform => 'parse_simple_list' ,
    • },
    • },
    • },
  • 7.
    • =head2 parse_simple_list
    • Return a simplified text representation of the li elements under a node.
    • =cut
    • sub _xclient_parse_simple_list {
    • my ( $self , $list_node ) = @_ ;
    • # Find the child elements
    • my @li_elements = $list_node ->find_xpath( 'li' )->get_nodelist();
    • # Render them as text
    • my @simplified = map {
    • $self ->_xclient_trim_cell( $_ ->as_text)
    • } @li_elements ;
    • # And give them back...
    • return @simplified ;
    • }
  • 8.
    • # Send the shipment ID
    • $mech ->submit_form_ok({
    • with_fields => { shipment_nr = $shipment_id }
    • }, "Shipment ID submitted" );
  • 9.
    • # Check we're in the right place, and then submit the form
    • unless ( $mech ->uri->path eq '/Fulfilment/Selection' ) {
    • die "Expecting to be on /Fulfilment/Selection, actually: " .
    • $mech ->uri->path
    • }
    • # Send the shipment ID
    • $mech ->submit_form_ok({
    • with_fields => { shipment_nr = $shipment_id }
    • }, "Shipment ID submitted" );
  • 10.
    • # Check we're in the right place, and then submit the form
    • unless ( $mech ->uri->path eq '/Fulfilment/Selection' ) {
    • die "Expecting to be on /Fulfilment/Selection, actually: " .
    • $mech ->uri->path
    • }
    • # Send the shipment ID
    • $mech ->submit_form_ok({
    • with_fields => { shipment_nr = $shipment_id }
    • }, "Shipment ID submitted" );
    • # Check we didn't get any logical errors
    • if ( $mech ->as_data->error_message ) {
    • die "HTTP request passed, but the application complained: " .
    • $mech ->as_data->error_message;
    • }
  • 11.
    • __PACKAGE__->create_fetch_method(
    • method_name => 'flow_mech__fulfilment__packingexception' ,
    • page_description => 'packing Exception Page' ,
    • page_url => '/Fulfilment/PackingException'
    • );
    • __PACKAGE__->create_form_method(
    • method_name => 'flow_mech__fulfilment__packingexception_comment' ,
    • form_name => 'add_comments' ,
    • form_description => 'add comment' ,
    • assert_location => qr!^/Fulfilment/Packing/CheckShipmentException!,
    • transform_fields => sub { return { note_text => $_ [ 1 ] } },
    • );
    • #-------------------------------------------------------------------------------
    • $framework
    • ->flow_mech__fulfilment__packingexception
    • ->flow_mech__fulfilment__packingexception_comment(
    • "The quick brown fox ran over the lazy sheep dog"
    • );
    • #-------------------------------------------------------------------------------
    • # ->flow_mech__fulfilment__packingexception()
    • # Retrieving the packing Exception Page
    • # URL /Fulfilment/PackingException retrieved successfully via HTTP
    • # No status message shown
    • # Retrieved the packing Exception Page
    • # ->flow_mech__fulfilment__packingexception_comment( "Comment 1:70236" )
    • # URL [/Fulfilment/Packing/CheckShipmentException] matched assertion
    • # Searching for the add comment form
    • # Submitting add comment form
    • # URL /Fulfilment/Packing/CheckShipmentException?shipment_id=1630767 retrieved successfully via HTTP
    • # No status message shown
  • 12.
    • # Look for our purchase order
    • $flow
    • ->flow_mech__goodsin__stockin
    • ->flow_mech__goodsin__stockin_search({
    • purchase_order_number => $purchase_order_id
    • });
    • # Did we find it?
    • is(
    • $flow ->mech->as_data->{ 'products' }->[ 0 ]->{ 'PID' },
    • $product_id ,
    • "Found our product from the purchase order search"
    • );
    • # Check the packing slip
    • $flow
    • ->flow_mech__goodsin__stockin_packingslip( $flow ->stock_order->id )
    • # Is it sensible?
    • is(
    • $flow ->mech->as_data->{ 'product_data' }->{ 'Purchase Order' }->{ 'value' },
    • $purchase_order ->purchase_order_number,
    • "Purchase order matched from Stock Order page"
    • );
  • 13.
    • sub create_form_method {
    • my ( $class , %args ) = @_ ;
    • # This is a good place to check a user is using it correctly...
    • $class ->_auto_methods_check_params( %args ,
    • {
    • required => [ qw/
    • method_name form_name form_description assert_location
    • / ],
    • optional => [ 'form_button' , 'transform_fields' ],
    • });
    • $class ->meta->add_method(
    • $args { 'method_name' } => sub {
    • my ( $self , @user_options ) = @_ ;
    • $self ->show_method_name( $args { 'method_name' }, @user_options );
    • $self ->assert_location( $args { 'assert_location' } )
    • if defined $args { 'assert_location' };
    • my $transformed_fields = $args { 'transform_fields' } ?
    • $args { 'transform_fields' }->( $self , @user_options ) : {};
    • $self ->indent_note( "Searching for the $args {'form_description'} form" );
    • my $name = ref ( $args { 'form_name' }) eq 'CODE' ?
    • $args { 'form_name' }->( $self , @user_options ) :
    • $args { 'form_name' };
    • my $form = $self ->mech->form_name( $name );
    • unless ( $form ) {
    • croak "Couldn't find a form with name $args {'form_name'}" ;
    • }
    • $self ->mech->set_fields( %$transformed_fields );
    • my $button = ref ( $args { 'form_button' }) eq 'CODE' ?
    • $args { 'form_button' }->( $self , @user_options ) :
    • $args { 'form_button' };
    • $self ->indent_note( "Submitting $args {'form_description'} form" );
    • $self ->mech->submit_form(
    • fields => $transformed_fields ,
    • $button ? ( button => $button ) : ()
    • );
    • $self ->note_status;
    • return $self ;
    • }
    • );
    • }
  • 14. Come and work at Net-A-Porter
    • We’re hiring
    • It’s a lot of fun
    • Nice offices

×