Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question regarding CSS classes

    I am new to web programming so not sure if I am posting this in the correct forum.
    My question is regarding classes in CSS, I am trying to automate a web page, that runs only on IE, using python + selenium, the issue i am facing is as follows:

    There is a drop down list, which I guess dynamically populates the options, if i look at the source code the line shows up as:

    <select name="targetFirmwareVersion" groupName="Firmware Jobs" displayName="Firmware Job" nodePath="$property.nodePath.value"

    When i load the page 50% of the time the above line does not have class defined & 50 % of the time it has the class field as "valid":

    <select name="targetFirmwareVersion" class="valid" groupName="Firmware Jobs" displayName="Firmware Job" nodePath="$property.nodePath.value"

    with my automation script when ever the class name is present in the above line I am able to select any of the options & when it is not present, i cannot select the options in the drop down list. I wanted to know the reason why half the time class field is present & half the time it is missing?

    Any help is greatly appreciated

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I wanted to know the reason why half the time class field is present & half the time it is missing?

    Any help is greatly appreciated
    How can we get the possible errors in your code without seeing it?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is my python code:

    Code:
       def logon_to_server(self):
            '''The function logs on to the test server using the selenium web drivers'''
            self.driver = webdriver.Ie()
            self.driver.implicitly_wait(30)
            self.base_url = adddress
            self.verificationErrors = []
            self.driver.get(self.base_url)
            self.driver.find_element_by_id("j_username").clear()
            self.driver.find_element_by_id("j_username").send_keys(username)
            self.driver.find_element_by_id("j_password").clear()
            self.driver.find_element_by_id("j_password").send_keys(password)
            self.driver.find_element_by_xpath("//button[@type='button']").send_keys("\n")
    
        def firmwareupgrade(self, dpname):
            '''the function selects a delta package from the drop down list'''
            executebtn = self.driver.find_element_by_class_name('executeButton')
            retrybtn = self.driver.find_element_by_class_name('retryButton')
            if executebtn.is_displayed():
                executebtn.send_keys("\n")
            elif retrybtn.is_displayed():
                retrybtn.send_keys("\n")
            time.sleep(30)
            pdb.set_trace()
            Select(self.driver.find_element_by_class_name("valid")).select_by_visible_text(dpname)
            Select(self.driver.find_element_by_name("targetFirmwareVersion")).select_by_visible_text(dpname)
            or
            self.driver.find_element_by_xpath("//select/option[@value='%s']" % (dpname)).click()
    both the lines:
    Select(self.driver.find_element_by_name("targetFirmwareVersion")).select_by_visible_text(dpname) and
    self.driver.find_element_by_xpath("//select/option[@value='%s']" % (dpname)).click()[/CODE]
    always throw error: "WebDriverException: Message: u'An error occurred executing the click atom "

    whereas if the field "class=valid" is present in the htms/css then -"Select(self.driver.find_element_by_class_name("valid")).select_by_visible_text(dpname)" works fine.

    Here is the line from the webpage which sometimes have a class name & sometimes it does not.
    <SELECT name=targetFirmwareVersion groupName="Firmware Jobs" displayName="Firmware Job" nodePath="$property.nodePath.value">
    <SELECT name=targetFirmwareVersion class="valid" groupName="Firmware Jobs" displayName="Firmware Job" nodePath="$property.nodePath.value">


    Here is an extract from the webpage that I am trying to select

    Code:
    <FIELDSET class=ui-widget-content><LEGEND>Firmware Jobs</LEGEND>
    <P class="crudView ui-widget-content"><LABEL for=targetFirmwareVersion>Firmware Job </LABEL><SELECT name=targetFirmwareVersion groupName="Firmware Jobs" displayName="Firmware Job" nodePath="$property.nodePath.value"> <OPTION selected value=1.41.01_Up_to_1.48>1.41.01_Up_to_1.48</OPTION> <OPTION value=1.41.06_Up_to_1.48>1.41.06_Up_to_1.48</OPTION> <OPTION value=1.48_Down_to_1.41.01>1.48_Down_to_1.41.01</OPTION> <OPTION value=1.48_Down_to_1.41.06>1.48_Down_to_1.41.06</OPTION> <OPTION value=Down_to_3.20.04>Down_to_3.20.04</OPTION> <OPTION value=Mandatory_MDM9600-1.41.06_to_MDM9600-1.48>Mandatory_MDM9600-1.41.06_to_MDM9600-1.48</OPTION> <OPTION value=MDM9600-1.41.08_to_MDM9600-1.48>MDM9600-1.41.08_to_MDM9600-1.48</OPTION> <OPTION value="MDM9600-1.46.01 to MDM9600-1.47">MDM9600-1.46.01 to MDM9600-1.47</OPTION> <OPTION value="MDM9600-1.47 to MDM9600-1.46.01">MDM9600-1.47 to MDM9600-1.46.01</OPTION> <OPTION value=MDM9600-1.48_to_MDM9600-1.41.08>MDM9600-1.48_to_MDM9600-1.41.08</OPTION> <OPTION value=mdm_to_dmd>mdm_to_dmd</OPTION> <OPTION value=Optional_MDM9600-1.48_to_MDM9600-1.41.06>Optional_MDM9600-1.48_to_MDM9600-1.41.06</OPTION> <OPTION value=Up_to_3.20.05>Up_to_3.20.05</OPTION> <OPTION value=USB551L_1.48_Integrity>USB551L_1.48_Integrity</OPTION> <OPTION value=USB551L_1.48_Invalid>USB551L_1.48_Invalid</OPTION> <OPTION value=USB551L_1.48_to1.4F>USB551L_1.48_to1.4F</OPTION> <OPTION value=USB551L_1.4F_to_1.48>USB551L_1.4F_to_1.48</OPTION></SELECT> </P></FIELDSET> </TD></TR></TBODY></TABLE>
    <P><BUTTON style="MARGIN-LEFT: 60px" class="ui-state-default ui-corner-all crudView crudViewUpdateFormButton-1338850510200" onfocus=this.blur(); jQuery1338850449570="282">Queue Job</BUTTON></P></FORM></DIV></DIV></DIV></DIV>
    <DIV style="DISPLAY: none" id=dialog-ENDPOINT01338850464742-FirmwareUpgrade class=showing title="Execute Operation" jQuery1338850449570="270">
    In the above code sometimes the following line :

    <SELECT name=targetFirmwareVersion groupName="Firmware Jobs" displayName="Firmware Job" nodePath="$property.nodePath.value">

    has a class name 'class="valid"' & sometimes it doesn't, when the class field is present I am able to select the options & when it is not present I am not able to select any thing


    I know this is not the right place to post a selenium/python question but my question here is to understand why this particular element of the web page sometimes has "class=valid" and sometimes it doesn't. If I get some understanding I can try to modify my python code to get this thing to work.
    Last edited by dilbert_here; 06-05-2012 at 05:34 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •