Package: pyallied
pyallied wrapperCurrently supporting functionswebelement functionsdeffindElementsBy(self,xpath):...deffindElementBy(self,xpath):...defclick(self,xpath):...defclear(self,xpath):...defisClickable(self,xpath,index=None):...'''Simulates typing into the element.Args:value - A string for typing, or setting form fields. For setting file inputs, this could be a local file path.Use this to send simple key events or to fill out form fields:form_textfield = driver.find_element(By.NAME, 'username')form_textfield.send_keys("admin")This can also be used to set file inputs.file_input = driver.find_element(By.NAME, 'profilePic')file_input.send_keys("path/to/profilepic.gif")# Generally it's better to wrap the file path in one of the methods# in os.path to return the actual path to support cross OS testing.# file_input.send_keys(os.path.abspath("path/to/profilepic.gif"))'''deffillField(self,xpath,text):defnavigateto(self,urlstring):'''Gets the given attribute or property of the element.This method will first try to return the value of a property with the given name. If a property with that name doesn’t exist, it returns the value of the attribute with the same name. If there’s no attribute with that name, None is returned.Values which are considered truthy, that is equals “true” or “false”, are returned as booleans. All other non-None values are returned as strings. For attributes or properties which do not exist, None is returned.To obtain the exact value of the attribute or property, use get_dom_attribute() or get_property() methods respectively.Args:name - Name of the attribute/property to retrieve.Example:# Check if the "active" CSS class is applied to an element.is_active = "active" in target_element.get_attribute("class")'''defgetAttribute(self,xpath,AttributeName):'''Gets the given attribute of the element. Unlike get_attribute(), this method only returnsattributes declared in the element’s HTML markup.Args:name - Name of the attribute to retrieve.Usage:text_length = target_element.get_dom_attribute("class")'''defgetDomAttribute(self,xpath,AttributeName):...'''Gets the given property of the element.Args:name - Name of the property to retrieve.Usage:text_length = target_element.get_property("text_length")'''defgetProperty(self,xpath,PropertyName):...'''Whether the element is visible to a user.'''defisElementDisplayed(self,xpath):...'''Returns whether the element is enabled.'''defisElementEnabled(self,xpath):...'''Returns whether the element is selected.Can be used to check if a checkbox or radio button is selected.'''defisElementSelected(self,xpath):...'''Saves a screenshot of the current element to a PNG image file. ReturnsFalse if there is any IOError, else returns True. Use full paths in your filename.'''defcurrentElementScreenshot(self,xpath,screenShotSavingPath):...# action classdefactionClick(self,xpath):...defactionClickandHold(self,xpath=None):...defmoveToElement(self,xpath):...defmoveToElementWithOffset(self,xpath,xoffset,yoffset):...defmoveByOffsett(self,xoffset,yoffset):...defactionRelease(self,xpath=None):...defkeyDown(self,ModifierKey,key,xpath=None):...defkeyUp(self,ModifierKey,key,xpath=None):...defdouble_click(self,xpath:None):...defrighttClick(self,xpath=None):...defresetActions(self):...defsendKeys(self,*keys_to_send):...defsendKeysToElement(self,xpath,*keys_to_send):...'''Gets the full document screenshot of the current window as a base64 encoded stringwhich is useful in embedded images in HTML.Usage:driver.get_full_page_screenshot_as_base64()'''defget_screenshot_ofcurrentActive_page_in_base64(self):...'''Saves a full document screenshot of the current window to a PNG image file. ReturnsFalse if there is any IOError, else returns True. Use full paths in your filename.Args:filename: The full path you wish to save your screenshot to. This should end with a .png extension.Usage:driver.get_full_page_screenshot_as_file('/Screenshots/foo.png')'''defget_screenshot_ofcurrentActive_page_asFile(self,filename:str):...'''get_full_page_screenshot_as_png() → strGets the full document screenshot of the current window as a binary data.Usage:driver.get_full_page_screenshot_as_png()'''defget_screenshot_ofcurrentActive_page_asPNG(self):...'''Saves a screenshot of the current window to a PNG image file. ReturnsFalse if there is any IOError, else returns True. Use full paths in your filename.Args:filename: The full path you wish to save your screenshot to. This should end with a .png extension.Usage:driver.save_screenshot('/Screenshots/foo.png')'''defscreenshot_save_full_page_screenshot(self,filename):...'''returns the embedded text in the image.It returns a list of detected text, with each text element containing three types of information.Which are: the text, its bounding box vertices, and the confidence level of the text detection'''defget_embeddedText_from_image(self,path:str):...Drag and DropdefdragAndDrop(self,sourcexpath,destinationxpath):...defdragAndDropByOffset(self,sourcexpath,xoffset,yoffset):...window and frame functionsdefswitchToWindowUsingName(self,windowName):...defswitchtoWindowUsingHandle(self,windowNumber):...# frame switch, It’s possible to access subframes by separating the path with a dot,# and you can specify the frame by its index too. That is: driver.switch_to_frame("frameName.0.child")# would go to the frame named “child” of the first subframe of the frame called “frameName”. All frames are evaluated as if from *top*.defswithToFrame(self,xpath):...# Once we are done with working on frames, we will have to come back to the parent# frame which can be done using:defswithToParentFrame(self):...DropdowndefselectDropDownByValue(self,xpath,valueToSelect):...defselectDropDownByIndex(self,xpath,indexToSelect):elementPresense=super().WaitFor_PresenseOf_Element_Located(xpath)#elementVisibility=super().WaitFor_VisibilityOf_Element_Located(xpath)if(elementPresense):#if(elementVisibility):select=Select(self.browser.find_element(By.XPATH,xpath))select.select_by_index(indexToSelect)defselectDropDownByVisibleText(self,xpath,textToSelect):...defdeselectAllOptionsInDropDown(self,xpath):...defgetDefaultSelectedDropDownOptions(self,xpath):...defgetAllOptionInDropDown(self,xpath):...defdeselectByIndex(self,xpath,index):...defdeselectByValue(self,xpath,value):...defdeselectByVisibleText(self,xpath,text):...defgetFirstSelecteOption(self,xpath):...Alerts#alerts# Use this class to interact with alert prompts.# It contains methods for dismissing, accepting, inputting, and getting text from alert prompts.defacceptAlert(self):...defdismissAlert(self):...defgetAlertText(self):...defsendKeystoAlert(self,keysToSend):...other_miscellaneous'''returns the embedded text in the image.It returns a list of detected text, with each text element containing three types of information.Which are: the text, its bounding box vertices, and the confidence level of the text detection'''defget_embeddedText_from_image(self,path:str):''' compares images by pixel and return boolean tru or false'''defis_images_same_compare_by_pixel(self,sourceFile,destinationFile):''' returns the pdf file content as text'''defpdf_content_reader(self,file1):''' returns the mail body if the searched string found in in the mail body or subject'''defmail_outlook_search(self,userName,password,searchString:str,fromAddress:str):''' returns the mail attachments in a list'''defmail_outlook_Attachments(self,userName,password,searchString:str,fromAddress:str):''' returns the mail attachments content in a dictionary as attachment name as key and attachment content as value'''defmail_outlook_Attachments_Read(self,userName,password,searchString:str,fromAddress:str):Local Testingfollow the below steps to do local testbuild the distibuted codepysetup.pysdistbdist_wheeldo local installtion (not the dot in the command)py-mpipinstall-e.check with below command for successful installation verificationpy-mpiplistcheck the pyallied in visible with local path