CheshireCaat / playwright-with-fingerprints

Anonymous automation via playwright with fingerprint replacement technology.
MIT License
140 stars 11 forks source link

geolocation not work #11

Closed Romhast closed 1 year ago

Romhast commented 1 year ago

I am using the following codes to change geolocation, but it gives an error and the page is closed. What is the correct usage?

const { plugin } = require('playwright-with-fingerprints');
const { readFile, writeFile } = require('fs/promises');

(async () => {
  // Get a fingerprint from the server:
  const fingerprint = await plugin.fetch('', {
    tags: ['Microsoft Windows', 'Chrome'],
  });
  await writeFile('fingerprint.json', fingerprint);
  plugin.useFingerprint(fingerprint);

  // Launch the browser instance:

  const browser = await plugin.launchPersistentContext("", {headless: false,
    permissions: ["geolocation", "microphone"],
    locale: 'de-DE',
    timezoneId: 'Europe/Berlin',
    geolocation: { longitude: 41.890221, latitude: 12.492348 }});

  // The rest of the code is the same as for a standard `playwright` library:
  const page = await browser.newPage();
  await page.goto('https://mylocation.org/');
})();

image

CheshireCaat commented 1 year ago

This website gives an error even when using regular playwright, so the problem here is either in the website itself or in the library, but not in the plugin:

image

Example:

const { chromium } = require('playwright');

(async () => {
  const context = await chromium.launchPersistentContext('', {
    headless: false,
    permissions: ['geolocation', 'microphone'],
    locale: 'de-DE',
    timezoneId: 'Europe/Berlin',
    geolocation: { longitude: 41.890221, latitude: 12.492348 },
  });

  const page = await context.newPage();
  await page.goto('https://mylocation.org/');
})();

Try increasing the page load timeout and changing the waituntil property in the goto method options. For the future, check for an issue without using the plugin before reporting it.

Romhast commented 1 year ago

This website gives an error even when using regular playwright, so the problem here is either in the website itself or in the library, but not in the plugin:

image

Example:

const { chromium } = require('playwright');

(async () => {
  const context = await chromium.launchPersistentContext('', {
    headless: false,
    permissions: ['geolocation', 'microphone'],
    locale: 'de-DE',
    timezoneId: 'Europe/Berlin',
    geolocation: { longitude: 41.890221, latitude: 12.492348 },
  });

  const page = await context.newPage();
  await page.goto('https://mylocation.org/');
})();

Try increasing the page load timeout and changing the waituntil property in the goto method options. For the future, check for an issue without using the plugin before reporting it.

I used the codes you posted and it works fine for me. but playwright-with-fingerprints gives page not loading error

this normal playwright image

This too playwright-with-fingerprints image

CheshireCaat commented 1 year ago

Okay, I'll reopen the ticket, but at the moment I can't help - I don't have a similar problem on two different machines.

UPD: Please write what version of playwright and plugin version you are using. For now, you can try to remove some options from the launch yourself to understand which parameter is causing the problem.

Romhast commented 1 year ago

Okay, I'll reopen the ticket, but at the moment I can't help - I don't have a similar problem on two different machines.

thank you, not only for this site, if i change geolocation values, i can't do any search, it gives me page failed to load error every time.

UPD NPM list: +-- jsdom@22.1.0 +-- playwright-core@1.36.1 +-- playwright-with-fingerprints@1.3.0 `-- playwright@1.36.1

bablosoft commented 1 year ago

I can't reproduce issue either. Try to localize issue, by finding which exact option causes crash

Romhast commented 1 year ago

I can't reproduce issue either. Try to localize issue, by finding which exact option causes crash

Using permissions and geolocation at the same time causes a crash

bablosoft commented 1 year ago

Can you update minimal example

Romhast commented 1 year ago

Can you update minimal example

this code can be used without any crash but location information can never be allowed, it is changed to block every time

error occurs after adding this line permissions: ["geolocation"

const { plugin } = require('playwright-with-fingerprints');
const { readFile, writeFile } = require('fs/promises');

(async () => {
  // Get a fingerprint from the server:
  const fingerprint = await plugin.fetch('', {
    tags: ['Microsoft Windows', 'Chrome'],
  });
  await writeFile('fingerprint.json', fingerprint);
  plugin.useFingerprint(fingerprint);

  // Launch the browser instance:

  const browser = await plugin.launchPersistentContext("", {
    headless: false,
    permissions: ["microphone"],
    locale: 'de-DE',
    timezoneId: 'Europe/Berlin',
    geolocation: { longitude: 41.890221, latitude: 12.492348 }});

  // The rest of the code is the same as for a standard `playwright` library:
  const page = await browser.newPage();
  await page.goto('https://mylocation.org/');
})();

this code will crash because permission geolocation is used and it will crash 5-10 seconds after page load

const { plugin } = require('playwright-with-fingerprints');
const { readFile, writeFile } = require('fs/promises');

(async () => {
  // Get a fingerprint from the server:
  const fingerprint = await plugin.fetch('', {
    tags: ['Microsoft Windows', 'Chrome'],
  });
  await writeFile('fingerprint.json', fingerprint);
  plugin.useFingerprint(fingerprint);

  // Launch the browser instance:

  const browser = await plugin.launchPersistentContext("", {
    headless: false,
    permissions: ["geolocation", "microphone"],
    locale: 'de-DE',
    timezoneId: 'Europe/Berlin',
    geolocation: { longitude: 41.890221, latitude: 12.492348 }});

  // The rest of the code is the same as for a standard `playwright` library:
  const page = await browser.newPage();
  await page.goto('https://mylocation.org/');
})();
bablosoft commented 1 year ago

@CheshireCaat, we probably need to block permissions config key if it causes problems. What do you think?


@Romhast, in any case this example is sort of theoretical.

plugin.useProxy('127.0.0.1:8080', {
  // Change browser timezone according to proxy:
  changeTimezone: true,
  // Replace browser geolocation according to proxy:
  changeGeolocation: true,
});

Following code should be used to set geolocation and other browser settings related to language.

Romhast commented 1 year ago

@CheshireCaat, we probably need to block permissions config key if it causes problems. What do you think?

@Romhast, in any case this example is sort of theoretical.

plugin.useProxy('127.0.0.1:8080', {
  // Change browser timezone according to proxy:
  changeTimezone: true,
  // Replace browser geolocation according to proxy:
  changeGeolocation: true,
});

Following code should be used to set geolocation and other browser settings related to language.

if i use this code it won't crash but i can't change the location in any way. for example this code has no function.

await browser.setGeolocation({ latitude: 59.95, longitude: 30.31667 });

bablosoft commented 1 year ago

@Romhast, yes, because geolocation is set according to proxy automatically

Romhast commented 1 year ago

@Romhast, yes, because geolocation is set according to proxy automatically

I used fingerprint puppeteer, he has the same problem, for your information, I can take a video if you want.

bablosoft commented 1 year ago

Please create ticket with minimal number of actions in corresponding repository.

Also note, that priority will be far from high.

That is because the browser shouldn't crash, but it also shouldn't work as you expect to. Geolocation will be overridden with proxy settings anyway.

Romhast commented 1 year ago

Please create ticket with minimal number of actions in corresponding repository.

Also note, that priority will be far from high.

That is because the browser shouldn't crash, but it also shouldn't work as you expect to. Geolocation will be overridden with proxy settings anyway.

I wonder if this error exists only for the free version, could it be working properly in the premium version?