Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...