I'm finding that in some cases web pages are being rendered in one browser materially different than another browser. Specifically, Playwright running webkit is rendering a different structure than what I see when viewing the page in a standalone Chrome browser. No clue why and I can't do anything about it. This isn't a Playwright issue, it is rendering it the same way as a standalone browser would. Problem is I don't know of an up-to-date webkit based browser for Windows.
Is there a way using just Playwright to open a browser window that will let me manually enter a url and inspect the page as Playwright renders it?
You can use Playwright's codegen tool and open the webkit browser
playwright codegen -b webkit
In playwright.config you have option
channnel: "chrome"
So with this you will start chrome, not chromium driver.
You can also use the following command to launch a webkit browser with a desktop safari user agent:
npx playwright codegen -b webkit --device "Desktop Safari"
Related
I want to run the default browser, which we normally use for browsing.
I wouldn't want to run it with chrome webdriver.
it would be like opening the default browser pages "Chrome.exe" and not "Chromedriver.exe"
It's possible?
Yes, it is possible. You should learn Chrome DevTool Protocol(CDB). More details are here
It is low-level browser communication protocol. It communicates via WebSocket and you need to learn how to program WS and read CDP API.
Puppeter working in that way, directly communicate with Chrome.
Logic of Webdriver is to standartize some commands across all browsers.
Similarly, Firefox has Gecko protocol.
I have a use case where I need to click the browser extension/plugin while navigating the URL on headless browser in python library puppeteer.
await pyppeteer.launch(ignoreDefaultArgs='--disable extensions')
See Can't use chrome extensions when puppeteer open the chrome
I made a web scrape program using selenium.
This program is access target URL and download a file.
After updating Chrome, program does not work because chromedriver is old version.
How to do web scraping and file download not use chromedriver?
Thank all for reading.
I think it would be easier if you also updated ChromeDriver, that way your program would work again. Or you could install the previous Chrome version again.
But if you don't want that, you can use GeckoDriver with Firefox.
You can use a headless scrapper like Pupeppeteer. You also can update your Chrome driver to be compatible with your browser version that is the most recomended.
I have been trying to do web automation using Selenium. Is there any way to use a browser like Chrome or Firefox without actually installing them, like using some alternate options, or having portable versions of them. If I can use portable versions how do I tell Selenium to use it?
To use the browsers like google-chrome and firefox you have to install the full-blown browser.
You can find a detailed discussion in Is Chrome installation needed or only chromedriver when using Selenium?
As an alternative you can use the headless phantomjs browser as follows:
Code Block:
from selenium import webdriver
driver = webdriver.PhantomJS(executable_path=r'C:\WebDrivers\phantomjs.exe', service_args=['--ignore-ssl-errors=true', '--ssl-protocol=tslv1.0'])
driver.set_window_size(1920, 1080)
driver.get("https://account.booking.com/register?op_token=EgVvYXV0aCJ7ChQ2Wjcyb0hPZDM2Tm43emszcGlyaBIJYXV0aG9yaXplGhpodHRwczovL2FkbWluLmJvb2tpbmcuY29tLyo2eyJwYWdlIjoiL3JlZGlyZWN0LXRvLWpvaW5hcHAtbHA_bGFuZz1pdCZhaWQ9MTE4NzM2MCJ9QgRjb2RlKg4QAToAQgBY5dGK8gVgAQ")
print(driver.page_source)
driver.quit()
You can find a detailed discussion in PhantomJS can't load correctly web page
References
A couple of relevent discussions:
Do headless web browser need selenium WebDriver?
Difference of Headless browsers for automation
Install Selenium typing pip install selenium.
It comes with a portable version of Chrome browser, no need to manually install any browser for this.
Chrome will show this message to indicate that it is being 'remote controlled:
"Chrome is controlled by automated test software"
my problem is, that I wrote some python scripts, which are working fine. Now I have to get them to work on an ubuntu server. The problem is, that I need to use the chromedriver (selenium) and ofc there cant be an open browser at the server. So is there a way to use selenium with a server?
What you need is called 'Headless' editions of a browser.
These headless browsers don't open up as a browser but run in the background for you to perform scripts on.
Try searching for Headless + 'The browser driver you use'
Here is a quick tutorial to get you started: https://medium.com/#pyzzled/running-headless-chrome-with-selenium-in-python-3f42d1f5ff1d