Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

css - How to go back from child divs to main parent div container in Selenium WebDriver using Python?

After putting information at input class="input-medium" and clicking at button with class="btn" that are nested by the first div with class="box-header red-background".

Now I want to go at div class="span12 box" to be able to enter other second div with class="box-content box-no-padding" and want to click on the link on the anchor link with class="buttons_datagrid" href="https://www.example.com/project..." title="Configure Task"

My Idea:

searchBtn = driver.find_element(By.XPATH, "//div[@id='input-search-global']//button[@class='btn']/i[@class='icon-search']")
searchBtn.click()

Works until here.

But then when I to access and click the link, it doesn't work:

configTask = driver.find_element(By.XPATH,"../../../../..//table[@id='data_table_tasks_wrapper']/tbody/tr[@role='row']//a[@title='Configure Task']")
    
configTask.click()
        <div class='box-header red-background'>
                <div class="actions-table">
                    <div class="row-fluid">
                        <div id="input-search-global" class="control-group span7" style="margin: 0">
                            <div class="controls">
                                <div class="input-append">
                                    <input class="input-medium" value="" type="text" placeholder="Search...">
                                    <button class="btn" type="button"><i class="icon-search"></i></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
        </div> 

        <div class="box-content box-no-padding">
             <div class="responsive-table">
                <div class="scrollable-area">
                    <div id="data_table_tasks_wrapper" class="dataTables_wrapper form-inline">
                        <div class="row-fluid">
                            <div class="dataTables_scroll">
                               <div class="dataTables_scrollBody" style="position: relative; overflow: auto; width: 100%; height: 159px;">
                                    <table class="table table-bordered table-striped dataTable" id="" role="grid" aria-describedby="">
                                        <tfoot> </tfoot>
                                        <thead style="visibility: collapse;"></thead>
                                        <tbody>
                                            <tr role="row" class="odd">
                                                <td class="sorting_1"">
                                                    <input class="task_select" type="checkbox" value="17851210">&nbsp;
                                                    <span class="label has-tooltip" title="task" style="background-color:#000">
                                                    <a class="buttons_datagrid" href="https://www.example.com/project/show-project-task?task_id=17851210" title="Configure Task" style=""> 
                                                        <i class="icon-edit"></i></a> <a class="buttons_datagrid has-tooltip view-dettaglio-note" title="" data-value="17851210" data-original-title="Note"> <i class="icon-file-alt"></i>
                                                    </a> 
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
             </div>
        </div>
 </div>
question from:https://stackoverflow.com/questions/65849175/how-to-go-back-from-child-divs-to-main-parent-div-container-in-selenium-webdrive

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...