Update dropdown selection based on PressKey

This commit is contained in:
vguruparan 2025-08-20 14:11:10 -05:00
parent 524c7ffcc8
commit 3081a0e197

View file

@ -63,14 +63,22 @@ public partial class PlaywrightWebDriver
else else
{ {
await locator.ClickAsync(); await locator.ClickAsync();
var optionLocator = page.Locator($"//div[text()='{action.Content}']"); if (!string.IsNullOrWhiteSpace(action.PressKey))
var optionCount = await optionLocator.CountAsync();
if (optionCount == 0)
{ {
Serilog.Log.Error($"Dropdown option not found: {action.Content}"); await page.Keyboard.PressAsync(action.PressKey);
return; await page.Keyboard.PressAsync("Enter");
}
else
{
var optionLocator = page.Locator($"//div[text()='{action.Content}']");
var optionCount = await optionLocator.CountAsync();
if (optionCount == 0)
{
Serilog.Log.Error($"Dropdown option not found: {action.Content}");
return;
}
await optionLocator.First.ClickAsync();
} }
await optionLocator.First.ClickAsync();
} }
} }
else if (action.Action == BroswerActionEnum.InputText) else if (action.Action == BroswerActionEnum.InputText)