Фикс устаревших функций
This commit is contained in:
@@ -15,9 +15,16 @@ public static class MicrosoftLoginHelper
|
|||||||
|
|
||||||
await page.WaitForURLAsync(new Regex("login\\.(microsoftonline|live)\\.com", RegexOptions.IgnoreCase), new PageWaitForURLOptions { Timeout = 60_000 });
|
await page.WaitForURLAsync(new Regex("login\\.(microsoftonline|live)\\.com", RegexOptions.IgnoreCase), new PageWaitForURLOptions { Timeout = 60_000 });
|
||||||
|
|
||||||
var useAnotherAccount = page.Locator("div#otherTile, #otherTileText, div[data-test-id='useAnotherAccount']");
|
var useAnotherAccount = page.Locator("div#otherTile, #otherTileText, div[data-test-id='useAnotherAccount']").First;
|
||||||
if (await useAnotherAccount.First.IsVisibleAsync(new LocatorIsVisibleOptions { Timeout = 2000 }))
|
try
|
||||||
await useAnotherAccount.First.ClickAsync();
|
{
|
||||||
|
await Assertions.Expect(useAnotherAccount).ToBeVisibleAsync(new() { Timeout = 2000 });
|
||||||
|
await useAnotherAccount.ClickAsync();
|
||||||
|
}
|
||||||
|
catch (PlaywrightException)
|
||||||
|
{
|
||||||
|
// Кнопка не появилась — пропускаем
|
||||||
|
}
|
||||||
|
|
||||||
var emailInput = page.Locator("input[name='loginfmt'], input#i0116");
|
var emailInput = page.Locator("input[name='loginfmt'], input#i0116");
|
||||||
await emailInput.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30_000 });
|
await emailInput.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30_000 });
|
||||||
@@ -33,15 +40,20 @@ public static class MicrosoftLoginHelper
|
|||||||
|
|
||||||
await page.WaitForSelectorAsync("button, input[type='submit'], a", new PageWaitForSelectorOptions { Timeout = 8000 });
|
await page.WaitForSelectorAsync("button, input[type='submit'], a", new PageWaitForSelectorOptions { Timeout = 8000 });
|
||||||
|
|
||||||
var kmsiYesNoVisible = await page.Locator("#idSIButton9, #idBtn_Back").First.IsVisibleAsync(new LocatorIsVisibleOptions { Timeout = 3000 });
|
var locator = page.Locator("#idSIButton9, #idBtn_Back").First;
|
||||||
if (kmsiYesNoVisible)
|
try
|
||||||
{
|
{
|
||||||
|
await Assertions.Expect(locator).ToBeVisibleAsync(new() { Timeout = 3000 });
|
||||||
var noBtn = page.Locator("#idBtn_Back");
|
var noBtn = page.Locator("#idBtn_Back");
|
||||||
if (await noBtn.IsVisibleAsync())
|
if (await noBtn.IsVisibleAsync())
|
||||||
await noBtn.ClickAsync();
|
await noBtn.ClickAsync();
|
||||||
else
|
else
|
||||||
await page.Locator("#idSIButton9").ClickAsync();
|
await page.Locator("#idSIButton9").ClickAsync();
|
||||||
}
|
}
|
||||||
|
catch (PlaywrightException)
|
||||||
|
{
|
||||||
|
// Кнопки не появились — пропускаем этот шаг
|
||||||
|
}
|
||||||
|
|
||||||
await page.WaitForURLAsync(url => !Regex.IsMatch(new Uri(url).Host, "login\\.(microsoftonline|live)\\.com", RegexOptions.IgnoreCase), new PageWaitForURLOptions { Timeout = 60_000 });
|
await page.WaitForURLAsync(url => !Regex.IsMatch(new Uri(url).Host, "login\\.(microsoftonline|live)\\.com", RegexOptions.IgnoreCase), new PageWaitForURLOptions { Timeout = 60_000 });
|
||||||
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
|
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
|
||||||
|
|||||||
Reference in New Issue
Block a user