Вы можете установить каталог по умолчанию для загрузки файлов при инициализации хромедрайвера:
import os
from selenium import webdriver
# Set the target subfolder based on the current working directory
dl_folder = '/downloads'
dl_location = os.path.join(os.getcwd(), dl_folder)
# Add the headless argument
chrome_options.add_argument('headless')
# Prepare a dict with additional preferences. This is where the magic happens:
prefs = {"download.default_directory": dl_location}
chrome_options.add_experimental_option("prefs", prefs)
# launch the driver
driver = webdriver.Chrome(executable_path= '/path/to/executable', chrome_options= chrome_options)
После этого вы нажимаете что-то, что инициализирует загрузку
exportbtn = driver.find_element_by_id('exporter-csv')
exportbtn.click()
И затем вы получаете самую последнюю добавлен файл из папки. Например, если это CSV, загрузите его в фрейм данных:
import glob
import pandas as pd
list_of_files = glob.glob(dl_location+ '/*')
latest_file = max(list_of_files, key=os.path.getctime)
df = pd.read_csv(latest_file)
Я не знаю, как напрямую получить имя файла или файл. Если есть что-то, мне любопытно услышать об этом.
Этот CSS на самом деле делает свое дело:
<style type="text/css">
table.radioWithProperWrap input
{
float: left;
}
table.radioWithProperWrap label
{
margin-left: 25px;
display: block;
}
</style>
<asp:RadioButtonList runat="server" CssClass="radioWithProperWrap" ....>
Вы можете взять переключатель и отдельную метку и установить свойство AssociatedControlID этой метки.
<table>
<tr>
<td>
<asp:RadioButton runat="server" ID="rdo" />
</td>
<td>
<asp:Label runat="server" ID="lbl" Text="Radio Text" AssociatedControlID="rdo" />
</td>
</tr>
</table>
попробуйте отрицательный стиль текста с отступом -20 пикселей работает для IE8