I am using seleniumBase sb.click("//div[@class='canvas case']/div")…
- User
I am using seleniumBase sb.click("//div[@class='canvas case']/div") sb.set_value("#design_mockup_config_case_attributes_position_top", "40") input("enter")
the page is fully loaded everything is fine but as i shared the element the element is hidden element i am sure it is because the element is hiden.
Element {#design_mockup_config_case_attributes_position_top} was not visible after 10 seconds! Traceback (most recent call last): File "d:\Programing\AutoPOD\teepublic.py", line 331, in main main_upload(sb, store, total_uploads) File "d:\Programing\AutoPOD\teepublic.py", line 121, in main_upload sb.set_value("#design_mockup_config_case_attributes_position_top", "40") File "D:\Programing\AutoPOD.venv\Lib\site-packages\seleniumbase\fixtures\base_case.py", line 7990, in set_value self.scroll_to(original_selector, by=by, timeout=timeout) File "D:\Programing\AutoPOD.venv\Lib\site-packages\seleniumbase\fixtures\base_case.py", line 5943, in scroll_to element = self.wait_for_element_visible( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Programing\AutoPOD.venv\Lib\site-packages\seleniumbase\fixtures\base_case.py", line 8701, in wait_for_element_visible return page_actions.wait_for_element_visible( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Programing\AutoPOD.venv\Lib\site-packages\seleniumbase\fixtures\page_actions.py", line 504, in wait_for_element_visible timeout_exception(ElementNotVisibleException, message) File "D:\Programing\AutoPOD.venv\Lib\site-packages\seleniumbase\fixtures\page_actions.py", line 255, in timeout_exception raise exc(msg) seleniumbase.common.exceptions.ElementNotVisibleException: Message: Element {#design_mockup_config_case_attributes_position_top} was not visible after 10 seconds! PS D:\Programing\AutoPOD>
- Assistant
Because the input field you're trying to modify is hidden (
type="hidden"), Selenium's standard methods likeset_valuewon't work because they expect the element to be visible on the page. To interact with hidden elements, you can use JavaScript to directly set the value.Here's how you can modify your code:
python# Instead of sb.set_value(), use execute_script() sb.execute_script( "document.getElementById('design_mockup_config_case_attributes_position_top').value = '40';" )This line uses JavaScript to directly set the value of the hidden input field. The
execute_scriptmethod runs the JavaScript code in the context of the current page, allowing you to manipulate elements that aren't accessible through standard Selenium methods.Alternatively, if you prefer using the CSS selector: