Selenium - field selection will not be saved via Remote Webdrive

I need to test a web application written in React. I want to select an option from the selection field:

HTML <select id="martial_status" class="form-control" name="martial_status"> <option value="" hidden="">---</option> <option value="1">wolny</option> </select> 

I am trying to set this field to "value" = 1 using two methods:

 martial_status = Select(driver.find_element(By.ID, "martial_status") martial_status.select_by_value('1') 

or

 el = driver.find_element_by_id("martial_status") for option in el.find_elements_by_tag_name('option'): if option.text == 'wolny': option.click() break 

Both of them work correctly only with the local web server:

 cls.driver = webdriver.Firefox() cls.driver.implicitly_wait(20) 

When I use remote Webdriver, the selected values ​​are not saved:

 cls.driver = webdriver.Remote( command_executor='http://xx.xx.xx.xx:5555/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX) 

The test does not extract any errors. From the Selenium_standalone_server console running on a remote server that runs a remote test, I assume that the selection is found:

 14:31:16.993 INFO - Executing: [find element: By.id: martial_status]) 14:31:17.002 INFO - Done: [find element: By.id: martial_status] 14:31:17.063 INFO - Executing: [tag name: 15 [[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status]]) 14:31:17.070 INFO - Done: [tag name: 15 [[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status]] 14:31:17.130 INFO - Executing: [get element attribute: 15 [[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status], multiple]) 14:31:17.143 INFO - Done: [get element attribute: 15 [[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status], multiple] 14:31:17.204 INFO - Executing: [find child elements: 15 [[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status], By.cssSelector: option[value ="1"]]) 14:31:17.212 INFO - Done: [find child elements: 15 [[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status], By.cssSelector: option[value ="1"]] 14:31:17.272 INFO - Executing: [is selected: 16 [[[[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status]] -> css selector: option[value ="1"]]]) 14:31:17.278 INFO - Done: [is selected: 16 [[[[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status]] -> css selector: option[value ="1"]]] 14:31:17.337 INFO - Executing: [click: 16 [[[[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status]] -> css selector: option[value ="1"]]]) 14:31:17.376 INFO - Done: [click: 16 [[[[FirefoxDriver: Firefox on LINUX (661c3804-f7e8-470a-b516-95ad449efb8b)] -> id: martial_status]] -> css selector: option[value ="1"]]] 

But after saving and re-entering, I see that the selection is not set. The same code, local webdriver and selected fields are in order. Any ideas that might solve this problem? :)

+5
source share
1 answer

You can use relative XPath to select an item. those. (//option[@value='1'])

Link : https://www.guru99.com/xpath-selenium.html

0
source

Source: https://habr.com/ru/post/1264937/


All Articles