selenium.common.exceptions.InvalidSelectorException: Message: An invalid or illegal selector was specified

selenium.common.exceptions.InvalidSelectorException: Message: An invalid or illegal selector was specified

I am trying to write a script to handle web pages that has multiple elements. This element once clicked will lead to a new window. But my script has problem in identifying the element. I need help to locate element and handle multiple windows

I am trying to write a script to handle web pages that has multiple elements. This element once clicked will lead to a new window. But my script has problem in identifying the element. I need help to locate element and handle multiple windows

I tried finding Xpath by using Chrome but it is not the same in Internet Explorer. I also tried using CSS selector it doesn't work. Says it is invalid.

Code for the function test_google_search_page: def test_google_search_page(self): driver=self.driver driver.get("http://xxxx.com") str1=driver.title print(str1)

    #get the window handles using window_handles
    window_before=driver.window_handles[0]
    print(window_before)

#driver.find_element_by_xpath("//*                   [@id='2ccb50dfc61122820032728dcea648fe']/div/div")
driver.find_element_by_css_selector("#\32  ccb50dfc61122820032728dcea648fe > div > div")
window_after=driver.window_handles[1]

driver.switch_to.window(window_after)
str2=driver.title
print(str2)
print(window_after)

self.assertNotEqual(str1,str2)
print('This window has a different title')
driver.switch_to.window(window_before)

self.assertEqual(str1,driver.title)
print('Returned to parent window. Title now match')

ERROR: test_google_search_page (main.GoogleOrgSearch)

Traceback (most recent call last): File "C:\Users\PSWN672P\AppData\Local\Programs\Python\Python37\Python programs\SNOW2.py", line 21, in test_google_search_page driver.find_element_by_css_selector("#\32 ccb50dfc61122820032728dcea648fe > div > div") File "C:\Users\PSWN672P\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 598, in find_element_by_css_selector return self.find_element(by=By.CSS_SELECTOR, value=css_selector) File "C:\Users\PSWN672P\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element 'value': value})['value'] File "C:\Users\PSWN672P\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\PSWN672P\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSelectorException: Message: An invalid or illegal selector was specified


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Selenium with Python

Selenium with Python

Selenium WebDriver With Python 3.x - Novice To Ninja

Selenium WebDriver With Python 3.x - Novice To Ninja

Selenium Python

Selenium Python - is one of the widely used tools used for Web Browser Automation, and offers a lot of functionality and power over a browser.