How to change proxy IP of selenium webdriver dynamically? - python

I‘m using Python & selenium writing a crawler program, once Chrome webdriver instance was created, is there a way to change the proxy IP dynamically? hope for your help, thanks in advance.

I don't believe you can change proxy without first destroying and creating a new browser instance. In my program where I implemented proxies I had a for loop create a new browser and then passed that browser as an argument to the functions I had created that needed it. Perhaps I am just ignorant of a way to dynamically do it, but as I recall the proxy information needs to be specified when the browser instance is created so again I would not think that what you are trying to do is possible...

Related

Can I declare 2 desired_cap in 1 script? One for hybrid app and one for the Chrome app?

I have a hybrid app with redirects on the chrome browser.
In order to make appium recognize both apps, is there a possibility to declare a double desired_cap?
I want to make the script to click on one of the hybrid app button, then after the redirect to chrome is done, a verification of the chrome page should be done (so we can know that the redirect was done correctly) and then we have the driver.back() which will lead us back to the hybrid testing app.
I know is wrong what I've wrote, but can't find the right way.. got the error that the __second__ is not defined.
My example:
Can anyone help me with that? Thanks in advance.
You don't need to change the Desired Capabilities and also it is not possible during the session.
You must switch between the context of session (WEB_VIEW or NATIVE):
When the chrome opened do this:
driver.switch_to.context['WEB_VIEW_chrome]
Check your verifications and then you can change the context to the Native to continue on your android application:
driver.switch_to.context['NATIVE_APP]
Here is my full answer on this:
https://stackoverflow.com/a/62284044/7302505

Is there any way to change chrome settings without opening a new browser in Selenium with Python?

I'm trying to make a selenium project and I wonder if there is a way to change browser settings without opening a new browser. For example I want to open up a browser with some proxy connection, after that I want to change the proxy server of that browser. Is it possible?
Yes, it's possible. You can use ChromeOptions. Check here for more info.

Getting the current url in the browser

I am trying to get the current url opened in my pc in any browser using python.
I tried selenium it worked but it opens up a new browser window. I only want to get the current url opened in the browser.
Any help would be appreciated.
use keylogger in python, that would easiest solution, orelse you should catch each and every packets in network.
Selenium isn't made for such purposes. It can be used to automate testing of websites or for website scraping. Selenium associated with a driver (like Chrome's driver for example) is just a fancy browser that let's you interact with it in a non-intrusive way.
If you need to interact with already running apps, you could attach to another process's memory and read stuff directly from there but it might be very messy.
Also, see: Interact with other programs using Python

Python selenium with chrome webdriver - change user agent

I am running some code with selenium using python, and I figured out that I need to dynamically change the UserAgent after I already created the webdriver. Any advice if it is possible and how this could be done? Just to highlight - I want to change it on the fly, after almost each GET or POST request I send
I would go with creating a new driver and copy all the necessary attributes from the old driver except the user agent.

How to automate Windows authentication in Python with selenium-rc?

I am using python to write selenium-rc test code for my server code. The server application is written with ASP.NET and is configured with "Windows authentication". The execution steps of my python code look like the following:
Start python main()
Create the selenium instance (say sel)
Start the selenium by calling sel.start()
Open the target URL with the selenium instance via calling sel.open(url)
Windows authentication dialog box pops up at this time
sel.open(url) is, by default, set to time out in 30 seconds while the authentication process is pending for input of username and password.
At this point, I could not find any way through selenium-rc interface to make it recognize the pop up dialog box. I google around and find out that the selenium-rc interface (in python) is for http authentication only- not Windows authentication.
I have tried to use autoit within selenium but still without luck.
Can any of you shed some light on this?
Thanks in advance.
marvinchen
Selenium has issues recognizing that window (try to search HTTP Basic Authentification for more details about it)
Basically, only thing which kinda works is to put username and password into URL request itself. Assuming your application runs on http://example.com the new url should look like this:
http://username:password#example.com
This solution works for me, but only using Google Chrome as a default browser for testing
There is now way you can sort it out easy and at this point unless I have missed something last few months it will only be FireFox who can fix this for you.
Read this blog how to sort it out:
http://applicationtestingtips.wordpress.com/2009/12/21/seleniumrc-handle-windows-authentication-firefox/

Categories

Resources