Giter VIP home page Giter VIP logo

Comments (17)

Snooz82 avatar Snooz82 commented on July 30, 2024

The problem is, that the TestCases are generated before Suite Setup.
So even if the file is modified at suite Setup it wouldn't have any impact, because generation is already done.

But:
What do you think of the following idea?

I add an option do DataDriver to call a spacific Keyword.

Like
Library DataDriver config_keyword=Config DataDriver

This Keyword can be defined by you globally or in each Suite individually.

I would design is so, that this Keyword must have a specific Interface, where it gets all configs from DataDriver and it must return a Dictionary where the content will be read as "new" config.

With this you could generade the CSV file, and define {'file': 'ga28rid6247hd.csv'} as a return value and DataDriver uses these information to create TestCases.

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

I would call this Keyword with BuiltIn Features so it could be a robot keyword or a Python one.

from robotframework-datadriver.

aniketnjoshi avatar aniketnjoshi commented on July 30, 2024

Thank you for your reply. When are you planning to add support for this request?

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

First i would like to know if this would suite your needs.

from robotframework-datadriver.

aniketnjoshi avatar aniketnjoshi commented on July 30, 2024

We are using xlsx file in data driver. As I understand, there would be way to provide keyword name which will be called where I can generate file and return file path in json format. Let me know if I understood it correctly. If this would be the way then it will satisfy my requirement.

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

Hi,

This is the proof of concept.

The Keyword gets all arguments, that DataDriver gets from Library import, as Robot Dictionary.
It has to return a dictionary with these keys you want to set/override.

Example

*** Settings ***
Library           OperatingSystem
Library           DataDriver    dialect=excel    encoding=utf_8   config_keyword=Config
Test Template     The Keyword

*** Test Cases ***
Test    aaa

*** Keywords ***
The Keyword
    [Arguments]    ${var}
    Log To Console    ${var}

Config
    [Arguments]    ${original_config}
    Log To Console    ${original_config.dialect}                #just a log of the original
    Create File    ${CURDIR}/test321.csv
    ...    *** Test Cases ***,\${var},\n123,111,\n321,222,      #generating file
    ${new_config}=    Create Dictionary    file=test321.csv     #set file attribute in a dictionary
    [Return]    ${new_config}                                   # returns {'file': 'test321.csv'}

Result:

==============================================================================
Test                                                                          
==============================================================================
excel
123                                                                   111
123                                                                   | PASS |
------------------------------------------------------------------------------
321                                                                   222
321                                                                   | PASS |
------------------------------------------------------------------------------
Test                                                                  | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================

I try to get time tomorrow and release this as beta, so that you can test it.

from robotframework-datadriver.

aniketnjoshi avatar aniketnjoshi commented on July 30, 2024

Thank you

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

You should be able to use it.
pip install --upgrade --pre robotframework-datadriver[XLS]

the version 0.4.0b2 include an option config_keyword=
This option enables you to name a keyword that will be called from DataDriver before it starts its work.

Example from previous post works.

The Config Keyword need to accept one argument, which will be the whole config with all values as robot framework dictionary.
And the keyword must return a dictionary that shall include all config keys that should be changed.

Config
    [Arguments]    ${original_config}
    ${new_config}=    Create Dictionary    file=new.csv    encoding=cp1252
    [Return]    ${new_config} 

from robotframework-datadriver.

aniketnjoshi avatar aniketnjoshi commented on July 30, 2024

Thank you @Snooz82 . This enhancement is working as expected. Could you please add this enhancement as a part of default installation.

from robotframework-datadriver.

lucagiove avatar lucagiove commented on July 30, 2024

Why not passing directly the configuration dictionary?

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

@lucagiove

How and when would you generate it?
The only solution would be a python variable file, that is imported before Robot Framework.

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

But then it must be python.
So you can also use a robot keyword.

from robotframework-datadriver.

aniketnjoshi avatar aniketnjoshi commented on July 30, 2024

Hi @Snooz82 ,
When are you planning to make this GA?

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

Hi @aniketnjoshi,

Maybe in the next two weeks. But you can use it.
It will stay compatible to this behavior.

from robotframework-datadriver.

aniketnjoshi avatar aniketnjoshi commented on July 30, 2024

Hi @Snooz82 ,

Could you please merge this enhancement?

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

@aniketnjoshi
Is available not with

pip install -U --pre robotframework-datadriver

from robotframework-datadriver.

Snooz82 avatar Snooz82 commented on July 30, 2024

Will be fixed with 1.0 Release

from robotframework-datadriver.

Related Issues (20)

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.