Skip to main content
Image

r/selenium


I am making a whatsapp group number extractor as my first project using selenium. But i got errors on literally 4th line of my code. help, I'm gonna cry.
I am making a whatsapp group number extractor as my first project using selenium. But i got errors on literally 4th line of my code. help, I'm gonna cry.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
settings =Options()
settings.add_argument("user-data-dir=./whatsapp_profile")
driver = webdriver.Chrome(options=settings)

print ("it ececuate further")
website= "https://web.whatsapp.com/"
driver.get(website)

* I don't even know the python basics. but with the help of our friendly dumb llm claude i am trying to make this number extractor.

* So selenium was working properly and opening whatsapp.web automatically but every time i run the code, I had to scan the WhatsApp web qr code again and again.

So Claude said to use the Options function and add code lines 2, 3, 4, 5, hoping it will save the Chrome session in a folder. So next time I go to WhatsApp web, I won't have to scan the QR. But Now Code executes up to line 5 and never reaches that print function on the 6th line. And it also doesn't open WhatsApp web anymore.

What do i do?
How do I solve the problem of scanning QR on every new code run?

Would anyone be kind enough to guide me through this project as a mentor in dm's, please. LLM's are dumb and asking them is a waste of time, but i don't have another option.


Ready to move from mockup to code? Start now with Codex, available with ChatGPT.
Image Ready to move from mockup to code? Start now with Codex, available with ChatGPT.


Load Ubolite chrome extension in "headless=new" mode
Load Ubolite chrome extension in "headless=new" mode

Hey, i tried loading extensions in chrome but i can't do it, i tried using crx & unpacked but none of this works, the weird thing is both of them works on brave but i can't have it working on chrome, any idea on how i can fix it for chrome?

chrome_options.add_extension(os.path.join(project_folder, 'tools', 'uBOLite.crx'))    chrome_options.add_extension(os.path.join(project_folder, 'tools', 'uBOLite.crx'))

chrome_options.add_argument(f"--load-extension={os.path.join(project_folder, 'tools', 'uBOLite')}")chrome_options.add_argument(f"--load-extension={os.path.join(project_folder, 'tools', 'uBOLite')}")

How to use firefox profile with selenium
How to use firefox profile with selenium

I have been trying to get this to work for about 90 minutes now and can't seem to figure it out.
I am using python but every search result is giving me a different answer and none seem to work.

Do i need to use Options() or FirefoxOptions()?

Use FirefoxProfile('path/to/profile') or just a 'path/to/profile' in the options?

The selenium docs also give this code: options.add_argument('-profile', '/path/to/profile'/) But that gives me a TypeError: ArgOptions.add_argument() takes 2 positional arguments but 3 were given.

I also tried option.profile = firefox_profile (tried just the path and FirefoxProfile())

If i try to use webdriver.Firefox(firefox_profile=firefox_profile, options=options) i get a TypeError: WebDriver.__init__() got an unexpected keyword argument 'firefox_profile'

I think i tried any combination of these things and none of them work. I am probably just forgetting something small but if someone maybe knows what i am doing wrong i love to hear it.

What is the correct way to get selenium to use a profile in firefox? I am learning to code and tThe assignment requires me to have selenium signed in to a profile.