Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
rsvore
Posts : 4
Join date : 2012-11-08

Check for img alt and continue for loop Empty Check for img alt and continue for loop

Thu Nov 08, 2012 8:18 pm
I have a for loop and I need to check id an img alt text is open. if not I don't want the loop to timeout but continue to the next number to look up. How can i do this? I'm also using Python and asked on the Python forum as well. Thanks.

Here is my loop, and th eif statement to catch if there is no "open" alt tag.
Code:

CSN = ['12275632444', '12275627859',  '12275627856']

       
        for CSNumber in CSN:
            driver.find_element_by_id("fnsearchuc_temp2__ctl14_tbSimple").clear()
            driver.find_element_by_id("fnsearchuc_temp2__ctl14_tbSimple").send_keys(CSNumber)
            driver.find_element_by_css_selector("span[title="Find Now"]").click()
            # need to check if no img open the go to next claim number then set errorNum = 1
            if not driver.find_element_by_css_selector("img[alt="Open:"]"): break

            time.sleep(1)
            driver.find_element_by_css_selector("img[alt="Open:"]").click()
            time.sleep(2)
            #x and y axis is based on the position of the screen scrap browser not the save dialog box
            self.save_click(570,540)
            time.sleep(2)
avatar
rsvore
Posts : 4
Join date : 2012-11-08

Check for img alt and continue for loop Empty using a try catch

Thu Nov 08, 2012 9:35 pm
I changed my code to this below and it's starting to work. but I get a long delay during the except.

Code:

CSN = open('inputCSN.txt', 'r')
        # set errorNum to 0 if 1 there was an problem
        errorNum = 0
       
        for CSNumber in CSN:
            driver.find_element_by_id("fnsearchuc_temp2__ctl14_tbSimple").clear()
            driver.find_element_by_id("fnsearchuc_temp2__ctl14_tbSimple").send_keys(CSNumber)
            driver.find_element_by_css_selector("span[title="Find Now"]").click()
            # need to check if no img open the go to next claim number then set errorNum = 1
            # if not driver.find_element_by_css_selector("img[alt="Open:"]"): break
            time.sleep(1)
            try:
                driver.find_element_by_css_selector("img[alt="Open:"]").click()
            except:
                outputCSN = open('outputCSN.txt', 'a')
                outputCSN.write('There was an error with CSN:'+CSNumber)
            time.sleep(2)
            #x and y axis is based on the position of the screen scrap browser not the save dialog box
            self.save_click(570,540)
            time.sleep(2)
avatar
rsvore
Posts : 4
Join date : 2012-11-08

Check for img alt and continue for loop Empty Re: Check for img alt and continue for loop

Thu Nov 08, 2012 10:03 pm
During the exception it takes 35 seconds before it moves on. not sure why.
Sponsored content

Check for img alt and continue for loop Empty Re: Check for img alt and continue for loop

Back to top
Permissions in this forum:
You cannot reply to topics in this forum