DEV Community

Discussion on: Advanced Automation Tips with Python | Selenium

Collapse
 
dkondraszuk profile image
dkondraszuk • Edited
def search(self):
        bot = self.bot
        bot.get('www.google.com')    

Why would you ever do that. self.bot.get... is just fine, no need to copy attributes.

bot.find_element_by_id('LoginBtn').click()
time.sleep(3)

If you are performing another operation after logging then time.sleep is not a good practice. For this you have better approach like implicit explicit waits.

Collapse
 
thedevtimeline profile image
Rashid

The objective in this post is to be more clear for those who are starting automation. So, in my view self.bot.get() not looks clean and organized. If we talk about waits, it causes different kinds of errors depending on website's speed. Even sometimes websites can cause internal errors so these waits will crash at that moment. Anyway, thank you for your comment maybe your approach will work for someone👍