{"id":6112,"date":"2022-09-26T04:39:15","date_gmt":"2022-09-26T04:39:15","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=6112"},"modified":"2022-09-26T04:39:15","modified_gmt":"2022-09-26T04:39:15","slug":"selenium-web-driver-commands-with-python","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/","title":{"rendered":"Selenium Web-driver Commands With Python"},"content":{"rendered":"<h2>Opening URL <\/h2>\n<p>The URL in Python Selenium is opened or fetched using the driver.get() method of the selenium module.<\/p>\n<h3>Time Delay<\/h3>\n<p>is a function used to delay the execution of code for the number of seconds given as input to <strong>time.sleep()<\/strong>. The time.sleep() command is used to sleep the window. You can use the time.sleep() function to temporarily halt the execution of your code. For illustration, you are staying for a process to complete or a file upload.<\/p>\n<h3>Find Elements<\/h3>\n<p>you\u2019ll need the locators from it if you want to perform any automated action on a web page. These are unique identifiers associated with the web elements such as text, buttons, tables, div, etc.<br \/>\nIt is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver provides the following ways for detecting web elements.<\/p>\n<ul>\n<li>Detect Element by Name<\/li>\n<li>Detect Element by ID<\/li>\n<li>Detect Element by Link Text<\/li>\n<li>Detect Element by Partial Link Text<\/li>\n<li>Detect Element by XPath<\/li>\n<li>Detect Element by CSS Selector<\/li>\n<li>Detect Element by Tag name<\/li>\n<li>Detect Element by Class name<\/li>\n<\/ul>\n<h3>Click On Web Elements<\/h3>\n<p>We can click a button( elements) with Selenium web driver in Python <strong>using the click method ( .click()<\/strong> ). First, we have to identify the button to be clicked with the help of any locators like id, name, class, xpath, tagname, or CSS as per mention as per mentioned above. Then we have to apply the click method ( <strong>.click()<\/strong> ) on it. A button in HTML code is represented by a button tagname.<\/p>\n<h3>Sendkeys in Selenium<\/h3>\n<p><strong>send_keys()<\/strong> is a method in Selenium that allows the Tester to type content automatically into an editable field while performing any tests for forms.  For example, to test a login page, the username and password fields require some data to be entered. The tester uses the send_keys() method to enter the field values.<\/p>\n<h3>Submitting a form in Selenium<\/h3>\n<p>There are many techniques for submitting a form in Selenium. One of the methods is to directly use the click() method on the form submitting button. The next method is to use the submit() method on the form page.<\/p>\n<p><strong>In the below e.g you can get an idea that how to do automation testing in  selenium with the python commands<\/strong><br \/>\n<code>URL=\"<a href=\"https:\/\/al3viewer.winsurtech.com\/\">https:\/\/al3viewer.winsurtech.com\/<\/a>\"<br \/>\nWEB_DRIVER_PATH=\".\/chromedriver\"<br \/>\ndef invalidLogin():<br \/>\n       driver = webdriver.Chrome(WEB_DRIVER_PATH)<br \/>\n       driver.get(URL)<br \/>\n       driver.find_element(By.LINK_TEXT, \"SignIn\").send_keys(Keys.ENTER)<br \/>\n       time.sleep(5)<br \/>\n       driver.find_element(By.ID, \"id_remember\").click()<br \/>\n       username = driver.find_element(By.ID, \"id_login\")<br \/>\n       username.click()<br \/>\n       username.send_keys(\"YourUsername\")<br \/>\n       password = driver.find_element(By.ID, \"id_password\")<br \/>\n       password.click()<br \/>\n       password.send_keys(\"Pa55worD\")<br \/>\n       loginForm = driver.find_element(By.ID, \"signin_form\")<br \/>\n       loginForm.submit()<br \/>\n       time.sleep(5)<br \/>\n       return True<br \/>\n invalidLogin = invalidLogin()<\/code><\/p>\n<p><small><em>StudySection provides a big list of certification exams through its online platform. The <a href=\"https:\/\/www.studysection.com\/french-language-and-concepts-advanced\">French Certification Exam<\/a> can help you to certify your skills to communicate in the French language. Whether you are new to the language or you are an expert in it, this French certification exam can test the ability of anybody\u2019s command the French language.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Opening URL The URL in Python Selenium is opened or fetched using the driver.get() method of the selenium module. Time<\/p>\n","protected":false},"author":1,"featured_media":6113,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[33,124],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Selenium Web-driver Commands With Python - SS Blog<\/title>\n<meta name=\"description\" content=\"It is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Selenium Web-driver Commands With Python - SS Blog\" \/>\n<meta property=\"og:description\" content=\"It is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-26T04:39:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2022\/09\/New-Project.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"Selenium Web-driver Commands With Python\",\"datePublished\":\"2022-09-26T04:39:15+00:00\",\"dateModified\":\"2022-09-26T04:39:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/\"},\"wordCount\":450,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"Python\",\"selenium\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/\",\"url\":\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/\",\"name\":\"Selenium Web-driver Commands With Python - SS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2022-09-26T04:39:15+00:00\",\"dateModified\":\"2022-09-26T04:39:15+00:00\",\"description\":\"It is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Selenium Web-driver Commands With Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Selenium Web-driver Commands With Python - SS Blog","description":"It is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/","og_locale":"en_US","og_type":"article","og_title":"Selenium Web-driver Commands With Python - SS Blog","og_description":"It is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver","og_url":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2022-09-26T04:39:15+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2022\/09\/New-Project.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"Selenium Web-driver Commands With Python","datePublished":"2022-09-26T04:39:15+00:00","dateModified":"2022-09-26T04:39:15+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/"},"wordCount":450,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["Python","selenium"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/","url":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/","name":"Selenium Web-driver Commands With Python - SS Blog","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2022-09-26T04:39:15+00:00","dateModified":"2022-09-26T04:39:15+00:00","description":"It is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/selenium-web-driver-commands-with-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Selenium Web-driver Commands With Python"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":270,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6112"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=6112"}],"version-history":[{"count":1,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6112\/revisions"}],"predecessor-version":[{"id":6114,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6112\/revisions\/6114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/6113"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=6112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=6112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=6112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}