For loop in playwright , variable come from excel cells

import openpyxl
# Load the Excel file
#workbook = openpyxl.load_workbook('data.xlsx')
workbook = openpyxl.load_workbook('C:\\Users\\chan\\Downloads\\data.xlsx')
sheet = workbook.active

# Iterate over the rows in the sheet
for row in range(2, sheet.max_row + 1):
    # Get the values for each cell in the row
    cell_value_1 = sheet.cell(row=row, column=1).value
    # Process the row data
    print ({cell_value_1})

from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright):


    with playwright.chromium.launch() as browser:

        context = browser.new_context()
        page = context.new_page()

    page.goto("https://abc.org /goods/all")
    page.goto("https://abc.org /login?redirect=/goods/all")
    page.get_by_label("Userid").click()
    page.get_by_label("Userid ").fill("chan ")
    page.get_by_label("Userid ").press("Tab")
    page.get_by_label("Password").fill("123456")
    page.get_by_label("Password ").press("Enter")
    page.get_by_role("listitem").filter(has_text="All Application Forms").click()
    page.get_by_role("button", name="Expand \"Filter\"").click()
    page.get_by_label("Conf. Ref #").click()
    page.get_by_label("Conf. Ref #").fill(cell_value_1)
    page.get_by_label("Conf. Ref #").press("Enter")
    with page.expect_popup() as page1_info:
        page.get_by_role("link", name=cell_value_1).click()
    page1 = page1_info.value
    page1.get_by_role("radio", name="YES").click()
    page1.get_by_role("button", name="Save").click()

    # ---------------------
    context.close()
    browser.close()


with sync_playwright() as playwright:
    run(playwright)

The code looks like a code, but I don’t think we can help you if we don’t know what’s the problem :confused:

The only thing I have found suspicious is:

Setting the same variable in a loop seems pointless. However, as I said before, I’m not sure if this is what you want.

This is just setting a parameter named “row” to the variable “row”. This is commonly done in many tutorials I’ve found out. It confuses the issue between the parameter name (on the left) and variable name (on the right) for noobies. I don’t think it’s helpful myself.

The problem is
It just do the last cell value in this for loop instead of all value in Column A in excel.

Well, it is because of the code piece I said was “suspicious”. You are setting the same cell_value_1 many times in a loop. Just that it is in a loop doesn’t automatically make the variable an array. A variable can contain only one value at a time. If you want to store many values then first you have to assign a list to a variable:

cell_values = list()

then you can append something to the list:

cell_values.append( something )

still not working!

How did you changed the program?