我一直在与滑动滑块的这个问题作斗争。当我滑动幻灯片时,一切正常,我收到错误,如图所示。下面是我尝试的代码。
class Program
{
private const string username = "username";
private const string password = "password";
public static async Task GetStarted()
{
//await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision).ConfigureAwait(false);
using (var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = false,
ExecutablePath = @"C:\Users\Owner\Downloads\chrome-win\chrome-win\chrome.exe",
DefaultViewport = ViewPortOptions.Default
}
).ConfigureAwait(false))
{
var page = await browser.NewPageAsync().ConfigureAwait(false);
await page.GoToAsync("https://c2c.huobi.br.com/vi-vi/login/").ConfigureAwait(false);
await page.TypeAsync(@"input[name='login_name']", username).ConfigureAwait(false);
await page.TypeAsync(@"input[name='password']", password).ConfigureAwait(false);
ElementHandle button = await page.QuerySelectorAsync(".login-btn").ConfigureAwait(false);
await button.FocusAsync().ConfigureAwait(false);
await page.Keyboard.PressAsync("Enter").ConfigureAwait(false);
Thread.Sleep(5000);
ElementHandle sliderElement = await page.QuerySelectorAsync(".slidetounlock").ConfigureAwait(false);
var slider = await sliderElement.BoundingBoxAsync().ConfigureAwait(false);
var sliderHandle = await page.QuerySelectorAsync(".nc_iconfont.btn_slide").ConfigureAwait(false);
var handle = await sliderHandle.BoundingBoxAsync().ConfigureAwait(false);
await page.Mouse.MoveAsync(handle.X = handle.Width / 2, handle.Y + handle.Height / 2).ConfigureAwait(false);
await page.Mouse.DownAsync().ConfigureAwait(false);
await page.Mouse.MoveAsync(handle.X = slider.Width, handle.Y + handle.Height /2).ConfigureAwait(false);
Console.ReadLine();
}
}
static async Task Main(string[] args)
{
await GetStarted().ConfigureAwait(false);
}
}