Code Monkey home page Code Monkey logo

dsf's People

Contributors

chudkins avatar

dsf's Issues

Detect if page load fails

If a requested page doesn't load, for example because network traffic is heavy or the server is busy, we may get a browser time-out page or something else that is totally not what we're expecting. We need a way to handle this gracefully, maybe by trying again a certain number of times before giving up.

Manage-Product should update data file when done with current product

When finished processing a product, update the Excel/CSV with the result of the operation.

Similarly, when beginning to process a product, check if it already has a status so we can run multiple times against the same data set without attempting to redo things that have already been done. For example, if working through a list of 100 items, a browser crash might stop it prematurely, but next time it's run it will notice that 27 items have already been processed and pick up where it left off.

Crash in Find-Product when using Chrome

Find-Product crashes when trying to dump debug info on link properties. Would probably be resolved by #36; also related to #28 because crash is due to empty property when calling Write-DebugLog.

Publish-Product should fail if category not found

Currently, if Publish-Product searches for a category and it doesn't find anything, it produces errors due to attempting to set a null radio button, but it cannot tell that the action has failed. Function needs better checking when searching for a category.

Changed empty table detection; needs testing.

Find-Product could be faster to return when subset matches are found

When searching for a product name, Find-Product will only return a hit for an exact match, but if products are found whose name or ID contains the search string it causes a long delay before the function returns. Investigate the reason for this and see if it can be sped up.

Need function to iterate and output object properties

This will be useful for debugging and save me from doing ad-hoc output lines here and there.

Use .PsObject,Properties to get all properties of whatever, then output them via Format-Table. This way, we should be able to handle almost anything without coding for anything in particular.

Several Quantity options not handled

  • Allow Buyer to Edit Quantity: This is a checkbox under "By Multiples" in the Settings section, but script doesn't deal with it.
  • Enforce Max Quantity Permitted in Cart
  • Each recipient set to a valid quantity (Multiple recipients)
  • Total quantity must add up to a valid quantity (Multiple recipients)

Get-Control should verify that it actually found the requested type

Function should validate requested type. For instance, when searching for a radio button we look for type "input" with ID matching the supplied parameter, but it's possible (with poorly designed web app) that ID matches something else instead because it's not unique. After getting a match, function should check that the control is of the requested type.

Remove dependency on Selenium (module)

I found it very helpful when just getting started, however this module provides very little actual functionality. Rewrite code that relies on this module's functions and just handle Selenium calls directly.

Stop accidentally using global variables in functions

$Browser is defined outside of any function and is therefore available in any function. To avoid unforeseen behavior later, and make script easier to understand, pay better attention to scoping and fix this particular instance.

Rework logging

Output needs to shift from random text on the console to timestamped transactions. Make an object that contains: Date & time; action; result.

Example:
2019-01-30 16:04:28; Add; TEST Product099; Success
2019-01-30 16:04:35; Change; TEST Product024; Fail (DSF refused to accept changes)

Ideally, this object can also be passed to Format-Table or similar, to be further manipulated. For example, take script output, then sort it by action or result, maybe filter out successful entries so you can see what went wrong.

PS> .\Manage-DsfProduct.ps1 -Credential $Blah -ProductFile .\TestData.csv | where Result -like "Fail*" | format-table -auto

Time                Action  Product             Result
----                ------  -------             ------
1/30/2019 4:04 pm   Change  TEST Product024     Fail (DSF refused to accept changes)

Find-Product needs to find an exact match

Find-Product should return one product that matches the requested Product ID, but instead it is returning anything that contains the Product ID. This results in a false positive, and failure to create a new product, when the ID (and Product Name) is unique but is a substring of an existing ID.

Update-Product should handle Fixed/Multiple/Advanced quantity options

This function eventually needs to support Fixed, Multiple, and Advanced options.

  • Fixed Quantities
  • Multiples
  • Advanced

For Fixed Quantities, you must create or edit a grid similar to the multiple lines on the pricing sheet. Add logic to handle this.

Until then, it's probably best to use "Advanced" option and specify the quantities there. Syntax is similar to regex, so something like "1..5|10|25|100" would work. See the DSF online help for more details.

All element interactions should be functions

Interactions with web form elements (checking a box, picking something from a list, etc.) should be wrapped in functions that also check for success of the attempted operation. For instance, when checking a box we need to verify that it is, indeed, checked before proceeding; if it doesn't work as expected, throw an exception instead of just continuing so we can handle it somehow.

Global config file needed

Looks like JSON is the way to go here; it's semi-human-readable and handles custom/nested objects as well as XML. Sample config file added; will rename when it's final.

Add function, maybe called Get-Config or similar, that finds and loads the file if it exists. (If it doesn't exist, companion function Save-Config or similar should create it with default values.)

Allow for customization of input field names

Users might wish to change the field names on the input sheet, but that's not easily done because they are hard-coded into the script, such as $Product.Threshold. Think of some way this could be written such that field names could be changed once and then used in the rest of the script.

Manage-Product add fails if new ID is a subset of existing product

When adding a product, we first search to make sure we aren't duplicating an existing name. However, if the new ID gets a match because it's a subset of something else, script just sits there at the search results page.

Check if any of the results is an exact match, and proceed if not.

Related: #15

Update-Product needs to handle pricing

Add code to handle basic pricing; later, add the trickier options such as price tiers.

Functions needed for this:

  • New-PriceRow, to make a new one.
  • Get-PriceRow, to find a row based on some reliable criteria.
  • Set-PriceRow, to modify an existing one, such as the default row you get with a new product.
  • Remove-PriceRow, to delete one.

Some of these should allow pipelining, so for example Get-PriceRow ... | Set-PriceRow -Price 1.45, or New-PriceRow | Set-PriceRow 2.87.

Split functions into a module for reuse

We're probably going to have more scripts to manage things like users and kitted products. Common functions need to be moved into a module so they can be shared. Manage-DSF.psm1 will contain functions that all scripts will need to use.

Skip action still prints warning if product ID is empty

When the operation is "Skip," script shouldn't care if the product data is valid or empty. This warning probably exists because it's supposed to print "Skipping product [whatever]" but if the ID is empty it can't. The way the warning is written, it implies the product was skipped because the ID is empty, when actually it was instructed to skip.

Fix this to make more sense, ahead of #28 logging rework.

Strip extra whitespace in Product ID

Often the input data contains extra spaces, such as ABC Fac Kit, so we need to implement a filter such that products won't be created with IDs like that. I think this should be fairly easy using regex.

Can't change ID and publish to category at the same time

In the case where product ID is changed, Publish-Product will fail to locate the product because we're searching for the old ID. We need to check if it was a "Change ID" operation, and search for the new ID instead if so.

Rewrite `-like $null` tests to work correctly

I've learned that $null is not "like" [System.Management.Automation.Internal.AutomationNull], which seems to be what some functions return. Therefore, $blah -like $null doesn't test correctly.

Go through and check all instances of -like and -notlike to ensure they will behave as desired.

Stale elements cause script to fail

Certain elements, such as the Manage Inventory checkbox, cause the page to change. (In this case, a section of the form that was disabled becomes enabled.) When this happens, the web element becomes stale and unusable.

In the Manage Inventory example, once the box is checked, when Set-CheckBox tries to verify it succeeded it cannot, because the reference is now stale.

Set-CheckBox and some other functions don't know much about the object they're working with, so my idea is to have a function that will look through the element's attributes (Name, ID, etc.) and find one it can use to find the element again.

Maybe there is some attribute, once an element has been found, that can be used to refresh it.

Get-PriceRow should actually parse price rows

I think if we treat each price row as an entity, storing not only its user-supplied values but entity IDs, it will allow for more flexibility when we need to deal with tiered pricing, multiple sheets, etc.

Look into building an object for this, as it could be helpful to have member functions. Either way, I'm wanting to allow something like this:

$PriceSheet | Get-PriceRow -RangeBegin $Qty | Set-PriceRow -NewPrice $Cost -Setup $SetupFee

Handle Excel files directly instead of CSV

It would be nice if this script could import data directly from Excel files, instead of requiring the input to be CSV.

One reason is that some product detail fields are rich text, and formatting is lost when exporting to CSV. Another reason is that testing becomes more tedious with the additional step of exporting the test data to CSV.

Script crashes if initial URL load fails

Today Firefox started but didn't load the URL at all.

New-Object : Exception calling ".ctor" with "0" argument(s): "The HTTP request to the remote WebDriver server for URL
http://localhost:64968/session timed out after 60 seconds."
At C:\Program Files\WindowsPowerShell\Modules\Selenium\1.1\Selenium.psm1:18 char:19
+ ...   $Driver = New-Object -TypeName "OpenQA.Selenium.Firefox.FirefoxDriv ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

Entire script crashed as a result of not finding the login fields or anything else. Figure out how to handle this more gracefully.

Upload-Thumbnail sanity check is useless

My attempt to catch if image type is supported does not work. When I supply a PDF as the thumbnail, DSF does not support this, but my test of -in supported image types is succeeding where it should fail.

Set-RichTextField needs to handle formatted text

It works in a rudimentary way, by invoking the iFrame's Click() event, which causes it to set focus on the text field. In the future, we will want to be able to input formatted text, so this function will need to be revamped after the rest of the script is actually working.

Update-Product should check if it's a kit

Many things about kitted products can be changed just like non-printed ones, such as image and description. However, there is an additional step between the product details and being able to finish editing; for a kit you'll have a "Next" button instead of "Finish." Update-Product should check if the current product is a kit, and skip through the "Products in Kit" section on its way to saving changes.

Detect when page is done loading

Need a reliable way of detecting if requested page has loaded completely. Example: After login page, storefront page begins to load; admin link is found but can't be clicked yet because "loading spinner" obscures it.

We need a way to wait until the element we want is available, which in this case means the "loading spinner" has cleared because the in-page scripts are satisfied it's done. Can we also wait for this, maybe by spying on the script?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.