Selenium + Python automation Test unittest Framework Learning (vi) pagination

Source: Internet
Author: User

The form in which the contact item is paginated is in the following form:

To get the total number of pages, traverse the function of paging, but because pagination is implemented in JavaScript, the page refreshes after each click of the OK button, the webelement element expires and cannot traverse the next paging operation. Reported staleelementreferenceexception error, so for this operation toss a day or give up.

The following functions are implemented for paging operations:

(1) Get the total number of pages and output

(2) Traversal operation ' previous page ', ' next page ' button, to enable paging function

(3) Enter the number of pages in the text box to enter the number of pages, click OK to achieve page turn function

defpage (): Driver=Login.driver#Get Total PagesL.findid (Driver,"Laypageid") Total_pages= Len (l.findscss (Driver,"a[href= ' javascript:; ']"))    Print("Total_pages is%s"%(total_pages))#Click the next page     forIinchRange (total_pages-1):        L.findclassname (Driver,"Next"). Click () #next: The next page of class name Time.sleep (2)    #Click on the previous page     forIinchRange (total_pages-1):        L.findclassname (Driver,"prev").Click () #prev: Previous page of class name Time.sleep (2)    #page entry in the input box, click     forIinchRange (1,total_pages+1):        L.findclassname (Driver,"Textboxid"). Send_keys (i)l.findclassname (Driver,"laypage_btn"). Click () time.sleep (2)

The above code is not the realization of the paging function, just to record the page in the implementation of the paging function encountered difficulties, so that later re-pick up the changes.

Selenium + Python automation Test unittest Framework Learning (vi) pagination

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.