I have been trying to understand why the following code does not work. I am intending to send a key to a search input that is on a different web tab and then press a button. After reading similar questions in the forum I think the element might either be hidden or wrapped. How to find this? Also sometimes the elements are in a list and have to be accessed by indexing. The examples I have studied are not like that. Any help will be appreciated.
from selenium import webdriver
from selenium.common.exceptions import *
webdriver_path = "C:/Users/escob/Documents/Projects/WebScrapingExample/chromedriver.exe"
magpie_url = 'https://www.musicmagpie.co.uk/start-selling/'
search_item = "9781912047734"
options = webdriver.ChromeOptions()
browser = webdriver.Chrome (webdriver_path, options = options)
browser.get(magpie_url)
sell_tab = browser.find_element_by_id('pills-media-tab')
sell_tab.click()
##I have tried the following code with no luck
#search_bar = browser.find_elements_by_name('searchString')
#search_bar = browser.find_elements_by_class_name('form-input')
search_bar = browser.find_element_by_xpath("//input[@name='searchString']")
#I am getting elements in a list, the examples I have seen do not need indexing
search_bar[0].send_keys(search_item)
button = browser.find_element_by_class_name(submit-media-search) #will this work?
button[0].click() #again in a list?
Thank you so much for your help from a beginner Seleniumista.