Skip to content

Commit 34f04e7

Browse files
authored
Merge pull request #1130 from visagang/features/vguruparan
Update dropdown selection based on PressKey
2 parents 524c7ff + 3081a0e commit 34f04e7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.DoAction.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,22 @@ await locator.ClickAsync(new LocatorClickOptions
6363
else
6464
{
6565
await locator.ClickAsync();
66-
var optionLocator = page.Locator($"//div[text()='{action.Content}']");
67-
var optionCount = await optionLocator.CountAsync();
68-
if (optionCount == 0)
66+
if (!string.IsNullOrWhiteSpace(action.PressKey))
6967
{
70-
Serilog.Log.Error($"Dropdown option not found: {action.Content}");
71-
return;
68+
await page.Keyboard.PressAsync(action.PressKey);
69+
await page.Keyboard.PressAsync("Enter");
70+
}
71+
else
72+
{
73+
var optionLocator = page.Locator($"//div[text()='{action.Content}']");
74+
var optionCount = await optionLocator.CountAsync();
75+
if (optionCount == 0)
76+
{
77+
Serilog.Log.Error($"Dropdown option not found: {action.Content}");
78+
return;
79+
}
80+
await optionLocator.First.ClickAsync();
7281
}
73-
await optionLocator.First.ClickAsync();
7482
}
7583
}
7684
else if (action.Action == BroswerActionEnum.InputText)

0 commit comments

Comments
 (0)