Как получить идентификаторы вариантов ответа других таблиц после выбора переключателя? - PullRequest
0 голосов
/ 19 сентября 2019
procesStartTime = time.asctime( time.localtime(time.time()) )
print ("Proces Start at :", procesStartTime)
#-------------------------This code block is to select all the options of Parent Table one by one.-------------------------#
#--------------------------------------------------------------------------------------------------------------------------#
for PT_row in PT_row_IDs:

    browser.find_element_by_xpath(".//input[@type='radio'][@displayname='" + str(PT_row) + "'" + "]").click()

    #-------------------------This code block is to identify the IDs of the answer option of "RAID Configuration" table.-------#
    #--------------------------------------------------------------------------------------------------------------------------#
    time.sleep(30)
    CT_1_row_IDs=[]
    CT_1 =  browser.find_element_by_xpath("//table[@id='module_options_" + str(CT_id1) +"'" + "]")

    #CT_1.find_elements_by_xpath("//*[@id=" + "'" + str(CT_id1) + "'" + "]/tbody/tr/td/table/tbody/tr[@class='flavored_option_display_enabled']")

    for CT_1_row in CT_1.find_elements_by_xpath(".//tr[not(@class)]"):
        if CT_1_row.get_attribute("id")!='':
            CT_1_row_IDs.append(CT_1_row.get_attribute("id").replace(":","_"))
            time.sleep(3)

    #-------------------------This code block is to identify the IDs of the answer option of "RAID Controller" table.----------#
    #--------------------------------------------------------------------------------------------------------------------------#
    CT_2_row_IDs=[]
    CT_2 =  browser.find_element_by_xpath("//table[@id='module_options_" + str(CT_id2) +"'" + "]")
    for CT_2_row in CT_2.find_elements_by_xpath(".//tr[not(@class)]"):
        if CT_2_row.get_attribute("id")!='':
            CT_2_row_IDs.append(CT_2_row.get_attribute("id").replace(":","_"))
            time.sleep(4)

    #-------------------------This code block is to identify the IDs of the answer option of "Hard Drives" table.--------------#
    #--------------------------------------------------------------------------------------------------------------------------#
    CT_3_row_IDs=[]
    CT_3 =  browser.find_element_by_xpath("//table[@id='module_options_" + str(CT_id3) +"'" + "]")
    for CT_3_row in CT_3.find_elements_by_xpath(".//tr[not(@class)]"):
        if CT_3_row.get_attribute("id")!='':
            CT_3_row_IDs.append(CT_3_row.get_attribute("id").replace("tr_","t_"))
            time.sleep(5)  

    print("")
    print("#----------For Answer Option ID: "+ PT_row +"-------------------------------------------------#")        
    print("#---------------------------------------------------------------------------------------------#")
    print("#---TABLE OPTIONS IDs - Each column reprsents the child table anser options Ids.--------------#")
    print("#---------------------------------------------------------------------------------------------#")
    print("")
    pd.set_option('display.max_colwidth', -1)
    df_CT_1_row_IDs  =  pd.DataFrame(CT_1_row_IDs, columns=['RAID Configuration'])
    df_CT_2_row_IDs  =  pd.DataFrame(CT_2_row_IDs, columns=['RAID Controller'])
    df_CT_3_row_IDs  =  pd.DataFrame(CT_3_row_IDs, columns=['Hard Drives'])

    df_finalChildTable_IDs=pd.concat([df_CT_1_row_IDs, df_CT_2_row_IDs, df_CT_3_row_IDs ], ignore_index=False,axis=1)
    df_finalChildTable_IDs=df_finalChildTable_IDs.fillna(" ")
    #df_finalChildTable_IDs=df_finalChildTable_IDs.style.set_properties(**{'text-align': 'left'})
    print(df_finalChildTable_IDs)

    CT_1_row_IDs=[]
    CT_2_row_IDs=[]
    CT_3_row_IDs=[]

    df_CT_1_row_IDs        = df_CT_1_row_IDs.iloc[0:0]
    df_CT_2_row_IDs        = df_CT_2_row_IDs.iloc[0:0]
    df_CT_3_row_IDs        = df_CT_3_row_IDs.iloc[0:0]
    df_finalChildTable_IDs = df_finalChildTable_IDs.iloc[0:0]

procesEndTime = time.asctime( time.localtime(time.time()) )
print ("Proces End at :", procesEndTime)
print("Total time taken: ",procesEndTime-procesStartTime)

Я хочу получить идентификатор из трех других таблиц (CT_1, CT_2 и CT_3) при выборе переключателей родительской таблицы.Здесь PT_row_IDs имеет список идентификаторов всех вариантов ответа в родительской таблице.

После запуска этого кода я получаю идентификаторы только для 1-й итерации.В PT_row_ID у меня есть 6 идентификаторов.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...