Merge pull request #1130 from visagang/features/vguruparan

Update dropdown selection based on PressKey
This commit is contained in:
Haiping 2025-08-20 14:15:06 -05:00 committed by GitHub
commit 34f04e7f1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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)