-2

i am trying to fill the title text box

i used page.locator('input[name="fname").fill("XYZ") but getting error. waiting for selector

tried: i tried multiple ways like xpath, title, name, etc. I am not getting a proper idea: actual HTML is: enter image description here

  • Are you table so share the URL of the form? We could provide better help if we're able to reproduce the problem you're asking about. – larsks Jul 05 '23 at 19:20
  • Please [edit] your question and remove the extra dots. Instead, add your code, as formatted text (use the `{}` button), as [mcve]. As is, it's impossible to help you. See also [ask]. – Robert Jul 05 '23 at 21:53

1 Answers1

0

The name of the hidden field in your code is not fname.

new_value = 'XYZ'

# To fill the visible field:
await page.get_by_label('First name: ').fill(new_value)

# To fill the invisible field, one option is to apply it with js inside the browser context:
await page.evaluate(f'document.getElementById("custId").setAttribute("value", "{new_value}")')
candre
  • 593
  • 3
  • 8