A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

New answers tagged

0

Did you try driver.close()? Quit() kills the browser, which probably does not give it the chance the trigger the events. Close() closes the active window but the browser stays open, although if it is the last window it might quit aswell, maybe you need to open an extra window first.


1

I've never done with with Python, but, have a few times with C#. I know you won't be able to copy/paste this, but, will maybe help point you in the right direction string cookieNameString = _driver.Manage().Cookies.GetCookieNamed("actualCookieName").Value; cookieNameString = "my new cookie value"; Cookie actualCookieName = new ...


0

I know this an old post, but there is something better you can do with Python to test an element does not exist. from selenium.common.exceptions import NoSuchElementException with self.assertRaises(NoSuchElementException): driver.find_element_by_id(element_id) If you want to check that you cannot see the element, use(as mentioned above) self....


6

You can either: Look for all element that match certain search criteria: if driver.find_elements_by_css_selector(my_locator): # No element found here Catch an exception when searching for a single instance: try: webdriver.find_element_by_css_selector(my_locator) except NoSuchElementException: # No element found here


0

Yes you can achieve this using profile: Just login to the system and save the login session, you can get profile folder by typing chrome://version in tab: Open path\Google\chrome folder goto user data folder Copy the path to Default folder Now set it in chromeoptions: chromeOptions:{'args': ['--user-data-dir=%yourpath%\\Local\\Google\\Chrome\\User Data'...


3

Your xpath locator is wrong , try the below xpath: /html/body/div/div/footer/md-toolbar/div/div[2]/img[2]/../../../../../../../../body[@class="layout-column md-dialog-is-showing"] The errors were , space after /html/body/div/div/footer/md- more than one space character after body[@class="layout-column You navigated back to parent only seven times, ../../...


0

Use will need to use getOptions() method of Select Class in Selenium. This will return a List of WebElements in the dropdown Sample Code for your reference : Select optionSelect = new Select(driver.findElement(By.id("dropdown_cities"))); List <WebElement> elementCount = optionSelect.getOptions(); Now you can iterate over this list and assert values ...


1

https://selenium-python.readthedocs.io/locating-elements.html The above link gives the selenium documentation for python. I Believe that you are trying to get all the text in option tag and store it in a list To get the text from multiple elements use below code: a= driver.find_elements(By.XPATH, '//select[@name="fromPort"]/option').text; print(a); or ( ...


Top 50 recent answers are included