Search code examples
playwrightplaywright-pythonplaywright-test

Getting value of input element


<input datatype="1" id="me9f88f1d-tb" aria-readonly="true" role="textbox" class="fld text text    fld fld_ro" ctype="textbox" li="me9f88f1d-img" maxlength="10" style=";width:12.100000000000001ch;" sue="1" tabindex="-1" readonly="readonly" type="text" value="3510823" work="1" title="3510823" originalvalue="3510823" prekeyvalue="3510823" stoptcclick="true">

I have an input in which I'm trying to capture the text by value="3510823" or title="3510823" and store it in a variable through Playwright (Python)

 reg = page.wait_for_selector("#me9f88f1d-tb").text_content()
    print (reg)

There is no error, however, the print is blank.

I would like to store the value, in this case "3510823" in a variable

(Translated by Google Translate)


Solution

  • Managed to capture the value, with:

    selector = '(//input[@id="me9f88f1d-tb"])[1]'
    reg_dup = page.eval_on_selector(selector, "(element) => element.value")
    

    thanks