Answers for "selenium and python"

9

selenium python

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
Posted by: Guest on April-10-2020
2

python selenium setup

from selenium import webdriver
import unittest

class example(unittest.TestCase):
  
    @classmethod
    def setUpClass(cls):

        cls.driver = webdriver.Chrome("C:Program Files (x86)chromedriver.exe")
        cls.driver.maximize_window()
        
    def test_login(self):
      
      self.driver.get("https://eu-uat2.weissr-cloud.com")
      
    @classmethod
    def tearDownClass(cls):

        cls.driver.quit()
        print("Test Completed")
        
if __name__ == '__main__':
  unittest.main()
Posted by: Guest on December-07-2020
-1

python selenium

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
Posted by: Guest on June-11-2021
2

selenium python example

import unittest
from selenium import webdriver
import time


class TestThree(unittest.TestCase):

    def setUp(self):
        self.startTime = time.time()

    def test_url_fire(self):
        time.sleep(2)
        self.driver = webdriver.Firefox()
        self.driver.get("https://app.simplegoods.co/i/IQCZADOY") # url associated with button click
        button = self.driver.find_element_by_id("payment-submit").get_attribute("value")
        self.assertEquals(u'Pay - $60.00', button)

    def test_url_phantom(self):
        time.sleep(1)
        self.driver = webdriver.PhantomJS()
        self.driver.get("https://app.simplegoods.co/i/IQCZADOY") # url associated with button click
        button = self.driver.find_element_by_id("payment-submit").get_attribute("value")
        self.assertEquals(u'Pay - $60.00', button)

    def tearDown(self):
        t = time.time() - self.startTime
        print("%s: %.3f" % (self.id(), t))
        self.driver.quit()

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestThree)
    unittest.TextTestRunner(verbosity=0).run(suite)
Posted by: Guest on May-27-2020

Code answers related to "selenium and python"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language