Forum Discussion

namtn's avatar
namtn
Occasional Contributor
2 years ago

select 1 data with input taken from excel file

I have issue, please help me

Currently I want to click on the Status box and select 1 data in it with that data taken from the excel file
for example: excel data file is Request -> then on the screen will click Request

 

I want keyword test , because tester for me don't know the code

  • KB1's avatar
    KB1
    Champion Level 2
    1. This is the code I use for my excel data. maybe It'll come in handy.
    2.  
    3. 1. Retrieve the data from the Excel file:

      javascript
       

     

     

    let excelApp = Sys.OleObject("Excel.Application");
    let workbook = excelApp.Workbooks.Open("path_to_your_excel_file");
    let sheet = workbook.Sheets("Sheet1");
    let data = sheet.Cells(1, 1).Value;

     

     

     
    • 2. Use UI automation to locate and interact with the Status box in your application:

      javascript
       

     

     

    let appProcess = Sys.Process("Your_Application_Process_Name");
    let window = appProcess.Window("Your_Window_Name");
    let statusBox = window.FindChild("Your_Status_Box_Name");
    statusBox.Click();

     

     

     
    • 3. Optionally, add necessary delays or synchronization points before proceeding further.

    • 4. Simulate typing the data into the Status box:

      javascript 
       

     

     

    statusBox.Keys(data);
    //Or for setItem
    statusBox.setItem(data);

     

     

    Make sure to replace "path_to_your_excel_file" with the actual path to your Excel file, "Sheet1" with the name of the sheet in your Excel file, "YourAppProcessName" with the actual process name of your application, and "Your_Status_Box_Name" with the proper name or identifier of the Status box in your application.

    Please let me know if you encounter any issues or if there's any additional information I can provide to assist you further.

    • namtn's avatar
      namtn
      Occasional Contributor

      thanks you, but I want keyword test , because tester for me don't know the code, Do you have any way?

      • KB1's avatar
        KB1
        Champion Level 2

        Never worked with keywords test. I really don't know... sorry.

        I think maybe rraghvani  can help you with that

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I don't work with Keyword Tests either, scripting is the way forward 😁

     

    I suggest you break things down into smaller pieces,

    • Record a keyword test to click the Status control, and then select the item Request.
    • Replace 'Request' with a variable
    • Record a keyword test to read data from your source
    • Store the data into a variable

    You should then be able to tie the two scenarios above, into one. 

     

    There's plenty of examples on the SmartBear website such as Data-Driven Testing

    • namtn's avatar
      namtn
      Occasional Contributor

      Yep, but in step:

      • Record a keyword test to click the Status control, and then select the item Request.
      • Replace 'Request' with a variable

      -> after selecting Request it will create an object in namemapping with xpath only of Request so can't convert Request to variable

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    It's difficult to explain step by step, but you have the option to change e.g. the value of "Front-end" to a variable, where myvariable = "Front-end"

     

    • namtn's avatar
      namtn
      Occasional Contributor

      Yep! but on my website there is no Item tag so there is no keyword ClickItem, currently it in Tag <li>