Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 46 characters in body; edited title
Source Link

Assert multiple IdsId's using for loop in selenium and python

I want to assert all ids in the list with for loop, my code is not working:

list = ["'block-views-news_of_the_day-block_1'", "'views_slideshow_singleframe_main_carousal_new_block-block_1-2'",
            "'block-views-recent_contents-block_1'","'block-views-recent_contents-block_2'","'block-views-home_page_events-block_1'",
            "'const-cont-home","block-block-13'", "'block-block-58'"]
    
for x in list:
self.assertTrue(self.driver.find_element_by_id(x))

Error
Traceback (most recent call last): File "C:\Users\xxxxx\xxxxx\Selenium Scripts\xxxr\TestCases.py", line 50, in test_flush_cache self.assertTrue(self.driver.find_element_by_id(x))
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 266, in find_element_by_id return self.find_element(by=By.ID, value=id_)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element {'using': by, 'value': value})['value']
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"'block-views-news_of_the_day-block_1'"}

Traceback (most recent call last): File "C:\Users\xxxxx\xxxxx\Selenium Scripts\xxxr\TestCases.py", line 50, in test_flush_cache self.assertTrue(self.driver.find_element_by_id(x))
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 266, in find_element_by_id return self.find_element(by=By.ID, value=id_)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element {'using': by, 'value': value})['value']
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"'block-views-news_of_the_day-block_1'"}

Assert multiple Ids using for loop selenium python

I want to assert all ids in the list with for loop, my code is not working:

list = ["'block-views-news_of_the_day-block_1'", "'views_slideshow_singleframe_main_carousal_new_block-block_1-2'",
            "'block-views-recent_contents-block_1'","'block-views-recent_contents-block_2'","'block-views-home_page_events-block_1'",
            "'const-cont-home","block-block-13'", "'block-block-58'"]
    
for x in list:
self.assertTrue(self.driver.find_element_by_id(x))

Error
Traceback (most recent call last): File "C:\Users\xxxxx\xxxxx\Selenium Scripts\xxxr\TestCases.py", line 50, in test_flush_cache self.assertTrue(self.driver.find_element_by_id(x))
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 266, in find_element_by_id return self.find_element(by=By.ID, value=id_)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element {'using': by, 'value': value})['value']
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"'block-views-news_of_the_day-block_1'"}

Assert multiple Id's using for loop in selenium and python

I want to assert all ids in the list with for loop, my code is not working:

list = ["'block-views-news_of_the_day-block_1'", "'views_slideshow_singleframe_main_carousal_new_block-block_1-2'",
            "'block-views-recent_contents-block_1'","'block-views-recent_contents-block_2'","'block-views-home_page_events-block_1'",
            "'const-cont-home","block-block-13'", "'block-block-58'"]
    
for x in list:
self.assertTrue(self.driver.find_element_by_id(x))

Error

Traceback (most recent call last): File "C:\Users\xxxxx\xxxxx\Selenium Scripts\xxxr\TestCases.py", line 50, in test_flush_cache self.assertTrue(self.driver.find_element_by_id(x))
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 266, in find_element_by_id return self.find_element(by=By.ID, value=id_)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element {'using': by, 'value': value})['value']
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"'block-views-news_of_the_day-block_1'"}

added 1102 characters in body
Source Link

I want to assert all ids in the list with for loop, my code is not working:

list = ["'block-views-news_of_the_day-block_1'", "'views_slideshow_singleframe_main_carousal_new_block-block_1-2'",
            "'block-views-recent_contents-block_1'","'block-views-recent_contents-block_2'","'block-views-home_page_events-block_1'",
            "'const-cont-home","block-block-13'", "'block-block-58'"]
    
for x in list:
self.assertTrue(self.driver.find_element_by_id(x))

Error
Traceback (most recent call last): File "C:\Users\xxxxx\xxxxx\Selenium Scripts\xxxr\TestCases.py", line 50, in test_flush_cache self.assertTrue(self.driver.find_element_by_id(x))
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 266, in find_element_by_id return self.find_element(by=By.ID, value=id_)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element {'using': by, 'value': value})['value']
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"'block-views-news_of_the_day-block_1'"}

I want to assert all ids in the list with for loop, my code is not working:

list = ["'block-views-news_of_the_day-block_1'", "'views_slideshow_singleframe_main_carousal_new_block-block_1-2'",
            "'block-views-recent_contents-block_1'","'block-views-recent_contents-block_2'","'block-views-home_page_events-block_1'",
            "'const-cont-home","block-block-13'", "'block-block-58'"]
    
for x in list:
self.assertTrue(self.driver.find_element_by_id(x))

I want to assert all ids in the list with for loop, my code is not working:

list = ["'block-views-news_of_the_day-block_1'", "'views_slideshow_singleframe_main_carousal_new_block-block_1-2'",
            "'block-views-recent_contents-block_1'","'block-views-recent_contents-block_2'","'block-views-home_page_events-block_1'",
            "'const-cont-home","block-block-13'", "'block-block-58'"]
    
for x in list:
self.assertTrue(self.driver.find_element_by_id(x))

Error
Traceback (most recent call last): File "C:\Users\xxxxx\xxxxx\Selenium Scripts\xxxr\TestCases.py", line 50, in test_flush_cache self.assertTrue(self.driver.find_element_by_id(x))
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 266, in find_element_by_id return self.find_element(by=By.ID, value=id_)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element {'using': by, 'value': value})['value']
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"'block-views-news_of_the_day-block_1'"}

Source Link

Assert multiple Ids using for loop selenium python

I want to assert all ids in the list with for loop, my code is not working:

list = ["'block-views-news_of_the_day-block_1'", "'views_slideshow_singleframe_main_carousal_new_block-block_1-2'",
            "'block-views-recent_contents-block_1'","'block-views-recent_contents-block_2'","'block-views-home_page_events-block_1'",
            "'const-cont-home","block-block-13'", "'block-block-58'"]
    
for x in list:
self.assertTrue(self.driver.find_element_by_id(x))