LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   In Selenium with python, after choosing drop down option page refresh but giving values of previous page (https://www.linuxquestions.org/questions/programming-9/in-selenium-with-python-after-choosing-drop-down-option-page-refresh-but-giving-values-of-previous-page-4175609264/)

project.linux.proj 07-05-2017 09:10 PM

In Selenium with python, after choosing drop down option page refresh but giving values of previous page
 
When I choose the next page from the drop down, page refreshes when I choose values by python program it gives me the value of previous page. Though the same query on firebug reaches the correct values but python program unable to fetch values in new page.


<tr>
<td headers="SINCE">18-FEB-16</td>
<td headers="TOKEN">
<span style="font-family:mono,new courier;font-size:14;color:darkgreen;font- weight:bold">vavFeth3</span>
</td>
<td headers="STATUS">

astrogeek 07-06-2017 12:08 AM

Please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.

While I am not familiar with Selenium (?), the HTML snippet you have posted does not have any obvious relevance to your problem description.

My first impression is that what you describe results from a browser page cache and is unrelated to any python code, but as you have not provided any useful details of the actual problem or the code it is impossible to say.

Please see this Site FAQ page and the links in it for help in asking a more complete question.

project.linux.proj 07-06-2017 09:15 AM

First I fetched values of first page in fetched_passwd then went to next page and then tried to fetch values of next page in fetched_passwd1 but still previous values are being stored. if I run the same query (//*[@headers='TOKEN']//following::span[2]) on firebug on new page it find correct values but python program it doesn't fetch new values.

Python Code:
Code:

fetched_passwd=browser.find_elements_by_xpath("//*[@headers='TOKEN']//following::span[2]")
sum=0
for i in fetched_passwd :
    print(i.text)
    sum=sum+1
    if(sum==9):
        break


next_page=browser.find_element_by_xpath("//*[@id='X01_5011970802493527']//following::option[1]").click()

fetched_passwd1=browser.find_elements_by_xpath("//*[@headers='TOKEN']//following::span[2]")
sum=0
for j in fetched_passwd1 :
    print(j.text)
    sum=sum+1
    if(sum==10):
        break


Below is the html code that I find on webpage.
Code:

<tr>
<td headers="SINCE">18-FEB-16</td>
<td headers="TOKEN">
<span style="font-family:mono,new courier;font-size:14;color:darkgreen;font- weight:bold">vavFeth3</span>
</td>
<td headers="STATUS">


project.linux.proj 07-13-2017 09:44 AM

Can anybody help me ?

firstfire 07-15-2017 02:07 AM

I guess you should wait for page to load. Add delay or, better, wait for some condition determining that page is loaded.

linux_project 06-21-2019 11:23 AM

@firstfire: Increasing timeout fixed it. Thanks


All times are GMT -5. The time now is 06:37 AM.