Skip to main content

pyseleniumbot - a wrapper based on selenium python

Project description

b'# Python Selenium Actionbot wrapper\r\n## Currently supporting functions\r\n### webelement functions \r\n\r\n python\r\n\r\n def findElementsBy(self, xpath):\r\n ...\r\n\r\n def findElementBy(self, xpath):\r\n ...\r\n\r\n def click(self, xpath):\r\n ...\r\n\r\n def clear(self, xpath):\r\n ... \r\n \r\n \r\n def isClickable(self, xpath, index=None):\r\n ...\r\n \r\n \'\'\'\r\n Simulates typing into the element.\r\n\r\n Args:\t\r\n value - A string for typing, or setting form fields. For setting file inputs, this could be a local file path.\r\n Use this to send simple key events or to fill out form fields:\r\n form_textfield = driver.find_element(By.NAME, \'username\')\r\n form_textfield.send_keys("admin")\r\n This can also be used to set file inputs.\r\n\r\n file_input = driver.find_element(By.NAME, \'profilePic\')\r\n file_input.send_keys("path/to/profilepic.gif")\r\n # Generally it\'s better to wrap the file path in one of the methods\r\n # in os.path to return the actual path to support cross OS testing.\r\n # file_input.send_keys(os.path.abspath("path/to/profilepic.gif"))\r\n \'\'\'\r\n\r\n def fillField(self, xpath, text):\r\n\r\n\r\n\r\n def navigateto(self, urlstring):\r\n\r\n\r\n \'\'\'\r\n Gets the given attribute or property of the element.\r\n\r\n This method will first try to return the value of a property with the given name. If a property with that name doesn\xe2\x80\x99t exist, it returns the value of the attribute with the same name. If there\xe2\x80\x99s no attribute with that name, None is returned.\r\n\r\n Values which are considered truthy, that is equals \xe2\x80\x9ctrue\xe2\x80\x9d or \xe2\x80\x9cfalse\xe2\x80\x9d, are returned as booleans. All other non-None values are returned as strings. For attributes or properties which do not exist, None is returned.\r\n\r\n To obtain the exact value of the attribute or property, use get_dom_attribute() or get_property() methods respectively.\r\n\r\n Args:\t\r\n name - Name of the attribute/property to retrieve.\r\n Example:\r\n\r\n # Check if the "active" CSS class is applied to an element.\r\n is_active = "active" in target_element.get_attribute("class")\r\n \'\'\'\r\n def getAttribute(self, xpath,AttributeName):\r\n \r\n \r\n \'\'\'\r\n Gets the given attribute of the element. Unlike get_attribute(), this method only returns \r\n attributes declared in the element\xe2\x80\x99s HTML markup.\r\n\r\n Args:\t\r\n name - Name of the attribute to retrieve.\r\n Usage:\t\r\n text_length = target_element.get_dom_attribute("class")\r\n \'\'\'\r\n def getDomAttribute(self, xpath,AttributeName):\r\n ...\r\n\r\n\r\n\r\n \'\'\'\r\n Gets the given property of the element.\r\n\r\n Args:\t\r\n name - Name of the property to retrieve.\r\n Usage:\t\r\n text_length = target_element.get_property("text_length")\r\n \'\'\'\r\n def getProperty(self, xpath,PropertyName):\r\n ... \r\n \'\'\'\r\n Whether the element is visible to a user.\r\n \'\'\'\r\n def isElementDisplayed(self, xpath):\r\n ...\r\n \'\'\'\r\n Returns whether the element is enabled.\r\n \'\'\'\r\n def isElementEnabled(self, xpath):\r\n ... \r\n\r\n \'\'\'\r\n Returns whether the element is selected.\r\n\r\n Can be used to check if a checkbox or radio button is selected.\r\n \'\'\'\r\n def isElementSelected(self, xpath):\r\n ...\r\n \r\n \'\'\'\r\n Saves a screenshot of the current element to a PNG image file. Returns\r\n False if there is any IOError, else returns True. Use full paths in your filename.\r\n \'\'\'\r\n def currentElementScreenshot(self, xpath,screenShotSavingPath):\r\n ...\r\n # action class\r\n\r\n def actionClick(self, xpath):\r\n ...\r\n\r\n def actionClickandHold(self, xpath=None):\r\n ...\r\n\r\n def moveToElement(self, xpath):\r\n ...\r\n\r\n def moveToElementWithOffset(self, xpath, xoffset, yoffset):\r\n ...\r\n\r\n def moveByOffsett(self, xoffset, yoffset):\r\n ...\r\n\r\n def actionRelease(self, xpath=None):\r\n ...\r\n\r\n def keyDown(self, ModifierKey, key, xpath=None):\r\n ...\r\n\r\n def keyUp(self, ModifierKey, key, xpath=None):\r\n ...\r\n\r\n def double_click(self, xpath: None):\r\n ...\r\n\r\n def righttClick(self, xpath=None):\r\n ...\r\n\r\n def resetActions(self):\r\n ...\r\n\r\n def sendKeys(self, *keys_to_send):\r\n ...\r\n\r\n def sendKeysToElement(self, xpath, *keys_to_send):\r\n ...\r\n \'\'\'\r\n Gets the full document screenshot of the current window as a base64 encoded string\r\n which is useful in embedded images in HTML.\r\n\r\n Usage:\t\r\n driver.get_full_page_screenshot_as_base64()\r\n \'\'\'\r\n def get_screenshot_ofcurrentActive_page_in_base64(self):\r\n ...\r\n\r\n \'\'\'\r\n Saves a full document screenshot of the current window to a PNG image file. Returns\r\n False if there is any IOError, else returns True. Use full paths in your filename.\r\n Args:\t\r\n filename: The full path you wish to save your screenshot to. This should end with a .png extension.\r\n Usage:\t\r\n driver.get_full_page_screenshot_as_file(\'/Screenshots/foo.png\')\r\n \'\'\'\r\n def get_screenshot_ofcurrentActive_page_asFile(self,filename:str):\r\n ... \r\n \'\'\'get_full_page_screenshot_as_png() \xe2\x86\x92 str\r\n Gets the full document screenshot of the current window as a binary data.\r\n\r\n Usage:\t\r\n driver.get_full_page_screenshot_as_png()\r\n \'\'\'\r\n def get_screenshot_ofcurrentActive_page_asPNG(self):\r\n ...\r\n\r\n \'\'\' \r\n Saves a screenshot of the current window to a PNG image file. Returns\r\n False if there is any IOError, else returns True. Use full paths in your filename.\r\n Args:\t\r\n filename: The full path you wish to save your screenshot to. This should end with a .png extension.\r\n Usage:\t\r\n driver.save_screenshot(\'/Screenshots/foo.png\')\r\n \'\'\'\r\n def screenshot_save_full_page_screenshot(self,filename):\r\n ...\r\n\r\n \'\'\'\r\n returns the embedded text in the image.\r\n It returns a list of detected text, with each text element containing three types of information. \r\n Which are: the text, its bounding box vertices, and the confidence level of the text detection\r\n \'\'\' \r\n def get_embeddedText_from_image(self,path:str):\r\n ... \r\n \r\n\r\n### Drag and Drop\r\n\r\npython\r\n\r\ndef dragAndDrop(self, sourcexpath, destinationxpath):\r\n ...\r\n\r\n def dragAndDropByOffset(self, sourcexpath, xoffset, yoffset):\r\n ...\r\n\r\n### window and frame functions\r\npython\r\n def switchToWindowUsingName(self, windowName):\r\n ... \r\n\r\n def switchtoWindowUsingHandle(self, windowNumber):\r\n ... \r\n # frame switch, It\xe2\x80\x99s possible to access subframes by separating the path with a dot,\r\n # and you can specify the frame by its index too. That is: driver.switch_to_frame("frameName.0.child")\r\n # would go to the frame named \xe2\x80\x9cchild\xe2\x80\x9d of the first subframe of the frame called \xe2\x80\x9cframeName\xe2\x80\x9d. All frames are evaluated as if from *top*.\r\n\r\n def swithToFrame(self, xpath):\r\n ... \r\n \r\n # Once we are done with working on frames, we will have to come back to the parent\r\n # frame which can be done using:\r\n\r\n def swithToParentFrame(self):\r\n ... \r\n\r\n\r\n### Dropdown\r\npython\r\n\r\n def selectDropDownByValue(self, xpath, valueToSelect):\r\n ... \r\n\r\n def selectDropDownByIndex(self, xpath, indexToSelect):\r\n elementPresense=super().WaitFor_PresenseOf_Element_Located(xpath)\r\n #elementVisibility=super().WaitFor_VisibilityOf_Element_Located(xpath)\r\n if(elementPresense):\r\n #if(elementVisibility):\r\n select = Select(self.browser.find_element(By.XPATH, xpath))\r\n select.select_by_index(indexToSelect)\r\n\r\n def selectDropDownByVisibleText(self, xpath, textToSelect):\r\n ... \r\n\r\n def deselectAllOptionsInDropDown(self, xpath):\r\n ... \r\n\r\n def getDefaultSelectedDropDownOptions(self, xpath):\r\n ... \r\n\r\n def getAllOptionInDropDown(self, xpath):\r\n ... \r\n\r\n def deselectByIndex(self, xpath, index):\r\n ... \r\n\r\n def deselectByValue(self, xpath, value):\r\n ... \r\n\r\n def deselectByVisibleText(self, xpath, text):\r\n ... \r\n\r\n def getFirstSelecteOption(self, xpath):\r\n ... \r\n\r\n### Alerts\r\npython\r\n #alerts\r\n # Use this class to interact with alert prompts. \r\n # It contains methods for dismissing, accepting, inputting, and getting text from alert prompts. \r\n def acceptAlert(self):\r\n ... \r\n def dismissAlert(self):\r\n ... \r\n def getAlertText(self):\r\n ... \r\n def sendKeystoAlert(self,keysToSend):\r\n ... \r\n'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyseleniumbot-1.0.14.tar.gz (18.3 kB view hashes)

Uploaded Source

Built Distribution

pyseleniumbot-1.0.14-py3-none-any.whl (19.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page