Reputation: 173
The code now:
await page.type('#filterdataTable > div.widget > input', "1234");
Can I use XPath instead of this CSS Selector?
Upvotes: 7
Views: 8686
Reputation: 1
Use
const [selector] = await scope.context.currentPage.$x(path);
await scope.context.currentPage.evaluate(
(element, value) => element.value = value, selector, text);
where xpath
is he XML path and text
holds the characters you want to type.
Upvotes: 0
Reputation: 28999
You can use page.$x()
to obtain the ElementHandle
of the element you want to select.
Then you can use elementHandle.type()
to type text into the input
field.
const example = await page.$x('//*[@id="filterdataTable"]/div[contains(concat(" ", normalize-space(@class), " "), " widget ")]/input');
await example[0].type('1234');
Upvotes: 12