Selenium iframe Выпуск данных - python

Что-то вроде этого:

// wrap IDisposable into using
using (SqlConnection connect = new SqlConnection("Put_Connection_String_Here"))
{
    connect.Open();

    // Make SQL readable and parametrized
    string sql = 
      @"select Tanım 
          from TümEnvanter$ 
         where Ekipman = @prm_Ekipman";  

    // wrap IDisposable into using 
    using (SqlCommand cmdTanim = new SqlCommand(sql, connect))
    {   
        //TODO: explicit typing Add(..., DbType...) is a better choice then AddWithValue
        cmdTanim.Parameters.AddWithValue("@prm_Ekipman", comboBox_ekipman.Text);

        // We want one record only; ExecuteScalar() instead of ExecuteReader() 
        // String interpolation shortens the code
        labelTanim.Text = $"Ekipman Tanımı: {cmdTanim.ExecuteScalar()} ";
    }
}
1
задан Moshe Slavin 14 February 2019 в 11:57
поделиться

1 ответ

На самом деле здесь есть два вложенных iframe. Это, в сочетании с некоторыми WebDriverWait, позволило мне прийти к следующему решению. Здесь я нахожу поле «Инструмент» и вводю в него текст:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.wait import WebDriverWait

options = Options()
options.add_argument("--headless")

driver = webdriver.Chrome(
    options=options, executable_path=r"C:\chromedriver\chromedriver.exe"
)
driver.implicitly_wait(10)

try:
    driver.get(
        "https://www.dukascopy.com/trading-tools/widgets/quotes/historical_data_feed"
    )

    driver.switch_to.frame(driver.find_element(By.ID, "widget-container"))
    driver.switch_to.frame(driver.find_element(By.TAG_NAME, "iframe"))

    # Wait for "Loading" overlay to disappear
    WebDriverWait(driver, 10).until(
        ec.invisibility_of_element_located((By.CLASS_NAME, "d-e-r-k-n"))
    )

    # Click "Instrument"
    driver.find_element(By.CLASS_NAME, "d-oh-i-ph-qh-rh-m").click()
    # Enter text into now-visible instrument field
    driver.find_element(By.CLASS_NAME, "d-e-Xg").send_keys("metlife")
finally:
    driver.quit()
0
ответ дан cody 14 February 2019 в 11:57
поделиться
Другие вопросы по тегам:

Похожие вопросы: