Microsoft Visual Studio not running Python file

Colm Gaffney 0 Reputation points
2024-08-30T14:14:25.92+00:00

Hi,

I'm new to Visual Studio & Python.

I was following a youtube training session to create a basic test case to test amazon.

When I run the below Python scripts the webpage opens with the first one but does nothing with the second one.

Please help

THIS CODE WORKS

from selenium import webdriver                                               
from selenium.webdriver.common.by import By                 
from selenium.webdriver.common.keys import Keys             
from selenium.webdriver.chrome.options import Options
#import pytest

chrome_options = Options()
chrome_options.add_argument("--disable-search-engine-choice-screen")     
driver = webdriver.Chrome(options=chrome_options)                      
driver.implicitly_wait(5)                                              
driver.maximize_window()                                               
driver.get("https://www.amazon.co.uk/") 




THIS CODE DOESN'T WORK and seems to skip over entire code

from selenium import webdriver                                               
from selenium.webdriver.common.by import By                 
from selenium.webdriver.common.keys import Keys             
from selenium.webdriver.chrome.options import Options
#import pytest

    def setup_method(self):                                                                 	
        chrome_options = Options()        
        chrome_options.add_argument("--disable-search-engine-choice-screen")                
        self.driver = webdriver.Chrome(options=chrome_options)                              
        self.driver.implicitly_wait(5) 
        self.driver.maximize_window()                                                       
        self.driver.get("https://www.amazon.co.uk/") 

  
Developer technologies Visual Studio Other
{count} votes

2 answers

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2024-09-03T03:11:16.2766667+00:00

    Hi @Colm Gaffney, 

    Welcome to Microsoft Q&A! 

    Visual Studio Code and Visual Studio are different products. The tag “Visual Studio” is related to Visual Studio, you can report VS Code issue to the GitHub-vscode forum where you would get support for this product.

    Thanks for your understanding. 

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. JunkuiChen-8339 0 Reputation points
    2024-09-03T03:33:05.7866667+00:00
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.chrome.options import Options
    def setup_method(self):                                                              	 		            chrome_options = Options()
    	chrome_options.add_argument("--disable-search-engine-choice-screen")
    	self.driver = webdriver.Chrome(options=chrome_options)
    	self.driver.implicitly_wait(5) 
    	self.driver.maximize_window()
    	self.driver.get("https://www.amazon.co.uk/") 
    if __name__ == '__main__':
    	setup_method()
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.