From 37e53615f6badff8abd36c32f03635e6a8f24f80 Mon Sep 17 00:00:00 2001 From: Onur YILDIZ <41267854+onur-yildiz@users.noreply.github.com> Date: Thu, 5 May 2022 16:54:25 +0300 Subject: [PATCH] fix: update the selectors broken by website update --- Puppeteer/Puppet.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Puppeteer/Puppet.cs b/Puppeteer/Puppet.cs index cb0e809..6fb5037 100644 --- a/Puppeteer/Puppet.cs +++ b/Puppeteer/Puppet.cs @@ -53,7 +53,7 @@ static async Task Login(Page page) await page.GoToAsync("https://www.myinstants.com/accounts/login/?next=/new/"); await page.TypeAsync("input[name=login]", creds[0]); await page.TypeAsync("input[name=password]", creds[1]); - await page.ClickAsync("div.input-field>button[type=submit]"); + await page.ClickAsync("button[type=submit]"); //await page.WaitForNavigationAsync(); await page.WaitForSelectorAsync("#id_name"); @@ -65,12 +65,13 @@ static async Task Upload(Page page, string name) Console.WriteLine("Uploading audio..."); await page.TypeAsync("#id_name", name + Guid.NewGuid().ToString()); var fileChooserDialogTask = page.WaitForFileChooserAsync(); - var termsCheckbox = await page.WaitForSelectorAsync("input[type=checkbox]"); await Task.WhenAll(fileChooserDialogTask, page.ClickAsync("input[name=sound]")); var fileChooser = await fileChooserDialogTask; await fileChooser.AcceptAsync("./media/output.mp3"); + var termsCheckbox = await page.WaitForSelectorAsync("input[type=checkbox]"); await page.EvaluateFunctionAsync("cb => cb.click()", termsCheckbox); - await page.ClickAsync("input[type=submit]"); + await page.FocusAsync("button[type=submit]"); + await page.Keyboard.PressAsync("Enter"); //await page.WaitForNavigationAsync(); await page.WaitForSelectorAsync("a.instant-link");