Can Selenium handle gathering multiple URLs at once?

Looking to create a Smoke test for a list of URLs by checking their titles for validity. Is this achievable? class identity(unittest.TestCase):

def setUp(self):

self.driver = webdriver.Chrome()
driver = self.driver
self.driver.implicitly_wait(30)

@data('https://idsvr-test.sc.com/account/signin','https://launchpad-test.sc.com/#&ui-      state=dialog','https://ambassador-test.sc.com/')  
def test_login_identity(self,url):  

self.driver.get("https://idsvr-test.sc.com/account/signin")
self.assertIn("Username / Password Sign In", self.driver.title)
elemU = self.driver.find_element_by_name("UserName").send_keys(User)
elemP = self.driver.find_element_by_name("Password").send_keys(sDecryptPassword)
self.driver.find_element_by_id("login").click()
try:

  self.assertEqual("MyTitle", self.driver.title)
  print("I asserted the Title")

except Exception as e:
  print(e)

try:
  self.driver.get("https://launchpad-test.sc.com/#&ui-state=dialog") 
  self.assertIn("Launch Pad",self.driver.title)
  ltitle = self.driver.title
  print( "New page" + ltitle)


except Exception as e:
 print(e)


 try:

  self.driver.get("https://ambassador-test.sc.com/")  
  self.assertIn("SC: Ambassador",self.driver.title)
  atitle = self.driver.title
  print(atitle)
 except Exception as e:
  print(e)

if name == "main": unittest.main()

Answer №1

It seems like a data-driven test scenario here. To simplify this process, the ddt package can be used:

DDT (Data-Driven Tests) enables running one test case with different test data, presenting it as multiple separate test cases.

from ddt import ddt, data

@ddt
class identity(unittest.TestCase):
    ...

    @data('url1', 'url2', 'url3')
    def test_login_identity(self, url):
        self.driver.get(url)
        # ...

By using the @ddt and @data decorators, a test method is generated automatically for each URL provided within the @data. In this instance, the unittest runner will execute 3 test methods.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigate away from tkinter.Enrry by clicking elsewhere

I developed a basic game where players can collect symbols for points while competing against each other. Below the Canvas, there are two entry boxes where players can input their names, which will be displayed as well. The issue I'm facing is that yo ...

The output of an Http Post request is displaying HTML content rather than the expected Csv

My current dilemma involves extracting a csv file from an aspx website. The direct link to the csv is not available, as it is generated by the server upon form submission. The method below successfully retrieves raw .csv data in Google App Script using Ur ...

Error during GANs execution: BrokenPipeError - Unable to proceed due to a broken pipe (Errno 32)

This particular example is sourced from this page and demonstrates the training of GANs (Generative Adversarial Networks). # Code for Deep Convolutional GANs goes here... # Some hyperparameters batchSize = 64 imageSize = 64 # Loading dataset and setting ...

Django - Unable to upload PDF file despite having the correct file path

Has anyone encountered an issue with uploading a PDF file to a database using forms, where the file fails to be sent to the server? models.py class Presse(models.Model): pdf = models.FileField() forms.py class PresseForm(forms.ModelForm): class M ...

Selenium Automation is having difficulty displaying the entire webpage

Currently, I am facing some difficulties while coding in Eclipse using Selenium for IE11 with Java. After executing commands like: mydriver.findElement(By.name("XXXXX")).click(); I find that the focus shifts to the current element on the webpage and is n ...

Using Selenium WebDriver in Golang to send keys while controlling the input

Has anyone had success opening a new tab using selenium webdriver for golang by pressing control+t, like this example shows for other languages? I've tried various combinations such as "ctrl t", "control t", "Control t", but haven't been able to ...

Python Selenium - Dragging Buttons Made Easy

I recently tested out the website "https://letcode.in/slider" and discovered that it offers two solutions for interacting with the slider - you can either click the button (Solution 1) or drag the button (Solution 2). I managed to write a simple ...

Testing the number of web browser instances

Whenever I execute my tests using TestNG, multiple browser instances are launched before the tests begin. This is how my testng.xml file looks: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> ...

Generate a new series in Python consisting of lists that contain the indexes corresponding to each item in the original list series

Apologies for the confusion in the title - finding it hard to explain this clearly. Let's say I have a series structured like this: s = pd.Series(index = ['a','b','c'], data = [['x','y','z'] ...

The DataFrame with Pandas MultiIndex

I have a specific numpy array: arr = np.array([1, 2, 3]) and I am looking to construct a Dataframe with a MultiIndex that has the following structure: df= 0 1 2 0 1 1 1 1 1 1 2 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 ...

Ensure that the web application is successfully logged into using MSTest, and verify that the application is fully loaded before proceeding

I've encountered an issue while using MSTest in Visual Studio 2019 with Selenium. It seems that after logging in, Selenium struggles to locate an element on the dashboard. Upon further investigation, I discovered that my login method within the OneTim ...

Tips for achieving a perfect score on my model's coverage tests

I have implemented coverage in my Django project, and the results are as follows: Name Stmts Miss Cover ---------------------------------------------------------------- test.apps.testapp.models.company ...

Locate the element in Selenium for navigating to the LinkedIn Job Page

I am currently attempting to scrape job listings on LinkedIn and have developed the following code: job = browser.find_elements_by_tag_name("a") c = [] ​ for i in job: c.append(i.text) print(c) print((len(c))) Unfortunately, the output ret ...

Basic Python function adjusting a variable that is not related

Why is the output of this seemingly simple code different than expected? I've searched for similar questions but haven't found one that addresses my issue. Here is the code in question: def test(f): f.append(0) f.append(0) return f ...

Using ExplicitWait could experience delays when an element is no longer present in the DOM

Currently, I am working on automating the tasks on this website. However, I am encountering challenges with using ExplicitWaitConditions to manage time effectively. The specific scenario I am dealing with is that when I click on the Login link or Submit b ...

Using Python to send a POST request with a JSON payload and custom headers

Looking for a way to get precise time in milliseconds and send a JSON request via a fast socket connection. However, experiencing a delay in response after running the script. Check out the code snippet below: import socket import time import ssl start_t ...

Java Selenium based framework using keyword-driven approach

I developed a unique Hybrid framework that combines Keyword driven and TestNG in Java. I utilize reflections in Java to execute the methods, allowing me to run all Action Keywords with just a single line of code (method[i].invoke()). However, this requir ...

Unable to locate the Xpath

Visit this webpage to be tested What would be the Xpath for the username and password fields? The code I am currently using is shown here. Even though I am sending keys using those Xpaths, the username and password fields are not accepting any input. I ...

Working with JSON data in a MySQL UPDATE statement

In my Python code, I am extracting information from a JSON message sent via ZeroMQ and attempting to insert it into MySQL. Here is the snippet of code that I have written: for i in json_msg["PropertyInfoMsg"]: db2 = MySQLdb.connect(host="localhost", u ...

Pygame sprite collision detection not functioning properly

For my Python programming class, I'm working on creating a spaceship game. My goal is to use sprite.spritecollideany to detect if my player sprite spaceship has collided with any of the asteroid sprites in the spriteGroup group. Unfortunately, no matt ...