I'm working with selenium in python and in this web page I want to choose between different options in a drop down menu and then enter some values. In that webpage, after I click on the "new order" button, a new windows pops up and I have to choose between symbols, for example, "USDCAD". After that I have to enter some values such as "take profit" and "stop loss". I don't know how to do these because unfortunately I don't know much about how web pages work and what HTML is and...! This is the code that I wrote for selecting between drop down menu options but I get error:
def fast_multiselect(driver, element_id, labels):
select = Select(driver.find_element_by_id(element_id))
for label in labels:
select.select_by_visible_text(label)
fast_multiselect(driver, 'symbol', "USDCAD")
And this is the error that I get:
selenium.common.exceptions.UnexpectedTagNameException: Message: Select only works on <select> elements, not on <th>
Complete code:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome('./chromedriver')
driver.get('https://www.mql5.com/en/trading')
time.sleep(10)
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@id='webTerminalHost']")))
time.sleep(10)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@title='New Order']/span"))).click()
time.sleep(5)
def fast_multiselect(driver, element_id, labels):
select = Select(driver.find_element_by_id(element_id))
for label in labels:
select.select_by_visible_text(label)
fast_multiselect(driver, 'symbol', "USDCAD")
I will be so thankful if you help me choose from the drop down menu and enter those values. And also if you explain some important and basic things or if a quick guide (maybe a useful link) which helps me understand how I should deal with HTML codes for basic jobs like my question.