Chrome driver geupdatet.

Vorbereitet für Tests um den Artikelparser zuverlässiger zu erstellen
This commit is contained in:
2023-08-18 09:45:11 +02:00
parent ff8649b314
commit 81ed7ae8d1
9 changed files with 61 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
// See https://aka.ms/new-console-template for more information // See https://aka.ms/new-console-template for more information
internal class Artikel public class Artikel
{ {
public int Amount { get; set; } public int Amount { get; set; }
public string GERName { get; set; } = ""; public string GERName { get; set; } = "";

View File

@@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Selenium.WebDriver" Version="4.10.0" /> <PackageReference Include="Selenium.WebDriver" Version="4.11.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -33,7 +33,11 @@ namespace CardmarketBot
{ {
ChromeOptions options = new ChromeOptions(); ChromeOptions options = new ChromeOptions();
options.AddArgument("start-maximized"); options.AddArgument("start-maximized");
options.AddArgument("incognito");
options.AddArgument("disable-popup-blocking");
options.AddArgument("force-device-scale-factor=0.8");
IWebDriver cd = new ChromeDriver(options); IWebDriver cd = new ChromeDriver(options);
cd.Url = @"https://www.cardmarket.com/de/OnePiece"; cd.Url = @"https://www.cardmarket.com/de/OnePiece";
cd.Navigate(); cd.Navigate();
@@ -89,7 +93,9 @@ namespace CardmarketBot
{ {
//if (id != "1121844928") continue; //if (id != "1121844928") continue;
//Console.WriteLine(id); //Console.WriteLine(id);
cd.Navigate().GoToUrl(string.Format(@"https://www.cardmarket.com/de/OnePiece/Orders/{0}", id)); //id = "1121395158";
cd.Navigate().GoToUrl(string.Format(@"https://www.cardmarket.com/de/OnePiece/Orders/1121395158", id));
//cd.Navigate().GoToUrl(string.Format(@"https://www.cardmarket.com/de/OnePiece/Orders/{0}", id));
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[3]/div[2]/div[2]/div/div")); element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[3]/div[2]/div[2]/div/div"));
Kunde kunde = Helper.ConvertToKunde(element.Text); Kunde kunde = Helper.ConvertToKunde(element.Text);

View File

@@ -1,11 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using OpenQA.Selenium.DevTools.V112.DOM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3.DataContracts namespace ConsoleApp3.DataContracts
{ {

View File

@@ -3,7 +3,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
static class Helper public static class Helper
{ {
public enum Porto public enum Porto
{ {
@@ -53,7 +53,7 @@ static class Helper
} }
internal static List<Artikel> ParseArtikeln(string text) public static List<Artikel> ParseArtikeln(string text)
{ {
List<Artikel> result = new List<Artikel>(); List<Artikel> result = new List<Artikel>();
string[] datas = text.Split("\r\n"); string[] datas = text.Split("\r\n");

View File

@@ -1,13 +1,6 @@
using ConsoleApp3.DataContracts; using ConsoleApp3.DataContracts;
using ConsoleApp3;
using ConsoleApp3.Contracts; using ConsoleApp3.Contracts;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Text;
using OpenQA.Selenium.DevTools.V112.Network;
using OpenQA.Selenium.DevTools.V112.Debugger;
using CardMarketBot; using CardMarketBot;
namespace CardmarketBot namespace CardmarketBot

View File

@@ -5,6 +5,8 @@ VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CardMarketBot", "CardMarketBot\CardMarketBot.csproj", "{4CB462A0-22BB-4E70-9C0B-203560329AFE}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CardMarketBot", "CardMarketBot\CardMarketBot.csproj", "{4CB462A0-22BB-4E70-9C0B-203560329AFE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CardMarketBotTests", "CardMarketBotTests\CardMarketBotTests.csproj", "{778573E1-5691-44C2-A897-C84FCC73FAC0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{4CB462A0-22BB-4E70-9C0B-203560329AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU {4CB462A0-22BB-4E70-9C0B-203560329AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CB462A0-22BB-4E70-9C0B-203560329AFE}.Release|Any CPU.ActiveCfg = Release|Any CPU {4CB462A0-22BB-4E70-9C0B-203560329AFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CB462A0-22BB-4E70-9C0B-203560329AFE}.Release|Any CPU.Build.0 = Release|Any CPU {4CB462A0-22BB-4E70-9C0B-203560329AFE}.Release|Any CPU.Build.0 = Release|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CardMarketBot\CardMarketBot.csproj" />
</ItemGroup>
</Project>

File diff suppressed because one or more lines are too long