Closed jgric2 closed 1 year ago
Hi, thank you for opening this issue,
can you provide more information? What is the type of authentication you are using Microsoft account or Session Token? you run it on desktop or server? Windows or linux? Do you use xvfb to run it?
Hi thanks for the fast response. I used the session token Run on my desktop Windows 10 No idea what xvfb is sorry. Thank you :)
Thank you for your information.
xvfb is a Linux package needed when you run your application on a server without an actual display screen, it will create a virtual one,
while you are running it on your Desktop then it is not needed,
do you see the Chromium browser open?
I see. Well I already had chrome open so maybe that was the problem. But I did not see a new chromium window open. Just out getting lunch I'll drive home soon and debug it again :)
Thank you for your information.
xvfb is a Linux package needed when you run your application on a server without an actual display screen, it will create a virtual one,
while you are running it on your Desktop then it is not needed,
do you see the Chromium browser open?
the chromium browser does not open.
Could it be the latitude and longitude hardcoded into Init()?
Thank you, I found the problem, you need to install chromium and other headless browser tools before running it because it uses playwright to control the headless browser and its Chromium and other WebKit tools must be installed, I installed it before that's why I forgot to put it in the readme file
to fix this you need to use PowerShell 7+ if you don't have you can download it here
then after building your project open PowerShell 7 in your project directory and run the following command
pwsh bin/Debug/netX/playwright.ps1 install
netX is your .Net version (eg. net6.0)
and wait it will install all needed browsers and tools for the playwright browser
then you can run your project again it must be working fine 😁
** thank you for informing me of this issue, I will add these steps to the readme file.
Thank you, I found the problem, you need to install chromium and other headless browser tools before running it because it uses playwright to control the headless browser and its Chromium and other WebKit tools must be installed, I installed it before that's why I forgot to put it in the readme file
to fix this you need to use PowerShell 7+ if you don't have you can download it here
then after building your project open PowerShell 7 in your project directory and run the following command
pwsh bin/Debug/netX/playwright.ps1 install
netX is your .Net version (eg. net6.0)
and wait it will install all needed browsers and tools for the playwright browser
then you can run your project again it must be working fine 😁
** thank you for informing me of this issue, I will add these steps to the readme file.
Yep that fixes it! thank you!
Is it possible to set the browser to headless?
unfortunately, it will not work because it can't bypass Cloudflare protection with headless, if you are planning to run it on a Linux server you can use xvfb, or just minimize the browser window in Desktop,
I will try to find a solution in the next updates...
unfortunately, it will not work because it can't bypass Cloudflare protection with headless, if you are planning to run it on a Linux server you can use xvfb, or just minimize the browser window in Desktop,
I will try to find a solution in the next updates...
I found a temporary solution! perhaps you can streamline it as I am not to familiar with microsoft playwright.
the solution I found was to get the current running process of all chrome windows (as I dont know how to get the Process ID of the Chromium browsers generated by microsoft playwright and they all have the same name "Chrome")
so before playwright spawns any chrome window get the current users chrome windows that are open using
Process[] p = Process.GetProcessesByName("chrome");
from there once the playwright has opened the chrome windows run this function
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, WindowShowStyle nCmdShow);
/// <summary>Enumeration of the different ways of showing a window using
/// ShowWindow</summary>
private enum WindowShowStyle : uint
{
Hide = 0,
ShowNormal = 1,
ShowMinimized = 2,
ShowMaximized = 3,
Maximize = 3,
ShowNormalNoActivate = 4,
Show = 5,
Minimize = 6,
ShowMinNoActivate = 7,
ShowNoActivate = 8,
Restore = 9,
ShowDefault = 10,
ForceMinimized = 11
}
public void HideChromium(Process[] pOriginal)
{
Process[] p2 = Process.GetProcessesByName("chrome");
for (int i = 0; i < p2.Length; i++)
{
var curr = p2[i];
var found = pOriginal.Where(x => x.Id == curr.Id).ToList();
if (found.Count() == 0)
{
IntPtr hWnd = curr.MainWindowHandle;
ShowWindow(hWnd, WindowShowStyle.Hide);
}
}
}
^ the hide code above will make it disappear from the taskbar :)
you can also set the browser size to (1,1) and use the header "--window-position=-4096,-4096", this will set the browser to be super small and then move it off screen, add that with hiding the window with the code above and it does a pretty good job at hiding the chromium browser.
Hope this helps :) Perhaps you can come up with a more efficent method to getting the process ID's from playwrite :)
Thank you for sharing your solution. I appreciate the effort you put into finding a solution to this issue.
I will definitely consider implementing your solution in the project as an option to hide the browser. However, I also want to try using the "visible" parameter in Playwright to see if that can hide the browser as well. If the "visible" parameter doesn't work, then I will consider implementing your solution as an alternative.
Again, thank you for your help and for taking the time to share your solution with me. Your assistance is greatly appreciated.
Thank you for sharing your solution. I appreciate the effort you put into finding a solution to this issue.
I will definitely consider implementing your solution in the project as an option to hide the browser. However, I also want to try using the "visible" parameter in Playwright to see if that can hide the browser as well. If the "visible" parameter doesn't work, then I will consider implementing your solution as an alternative.
Again, thank you for your help and for taking the time to share your solution with me. Your assistance is greatly appreciated.
no problem :) I will continue to debug throughout the night and get back to you with any findings, Ill keep a close eye on any updates you commit :)
I added the "Invisible" parameter, now you can set it to true it will start the chrome window out of the screen, about hiding it from the taskbar, thank you for the code you shared with me, but it will limit the project to be used in windows only, the project is cross-platform and I need to find a way that supported all platforms
thank you again, if I found any way to hide it from the taskbar too without limiting the project to windows only I will add it 😁
I added the "Invisible" parameter, now you can set it to true it will start the chrome window out of the screen, about hiding it from the taskbar, thank you for the code you shared with me, but it will limit the project to be used in windows only, the project is cross-platform and I need to find a way that supported all platforms
thank you again, if I found any way to hide it from the taskbar too without limiting the project to windows only I will add it 😁
No problems. I will add it to mine though as mine will only be windows based :). Thanks for your hard work!
Hi there, I cant seem to get the api to get past await chatGpt.WaitForReady();
it just hangs forever, any ideas?
Thanks James