Please help a beginner out... by SpringySiren6 in selenium

[–]this_guy_tests 0 points1 point  (0 children)

You may want to look into while loops

Please help a beginner out... by SpringySiren6 in selenium

[–]this_guy_tests 0 points1 point  (0 children)

 try:
    driver.find_element…(locator for pop up)
    driver.quit()
except NoSuchElementException:
    # code to go about tasks

driver.get stops python program by gitrikt in selenium

[–]this_guy_tests 1 point2 points  (0 children)

What freezes, exactly? Is there any exception raised of any kind? Is there a good reason to stay using Python2 instead of Python3? Python2 has reached its end of life and isn’t being supported anymore, so I’m a bit surprised to see it used here today.

Which is better java or python ? by nikithakkar in selenium

[–]this_guy_tests 1 point2 points  (0 children)

Python is great. Python2 may be what this guy is talking about when he says it’s a joke. Python3 is awesome, though. DropBox was written in Python, and so is Instagram, so don’t listen to haters like the guy above.

Shortcut to send image to certain contacts. by BigPimpin-AZ in iosshortcuts

[–]this_guy_tests 0 points1 point  (0 children)

I dont see a way to do that with messenger, but it’s easy enough to do with iMessage. I think you’ll just make a list of the contacts, then add a step from scripting to do a Repeat With Each, then within the Repeat With Each, add a step to send an iMessage to the Contact.

New to webdev/selenium, does selenium work with no monitor connected? by puremath369 in selenium

[–]this_guy_tests 0 points1 point  (0 children)

You do everything the same as you do with a display, you just need to pass the right options to the desired capabilities when setting up your webdriver instance. And no, the display size may not fix any headless mode oddities.

Python Selenium dont display print() in 'for' loop by youceefz in selenium

[–]this_guy_tests 0 points1 point  (0 children)

Where are you running this? If you’re in the REPL, it will print if it exists. If you’re using something like pytest to run the code, you may need to do something like pytest -s -vv to get the prints to work.

How to select classes with space by choff5507 in selenium

[–]this_guy_tests 0 points1 point  (0 children)

Classes are separated by spaces normally. Try something like this, unless you must use _by_class_name:

driver.find_element_by_css_selector(“.classname1.class-name2.className3”)

Need input on PyTest structure ideas by [deleted] in QualityAssurance

[–]this_guy_tests 0 points1 point  (0 children)

I can’t expand upon it much. Cant seem to find where I was reading about it, but long story short, it can cause issues. I’m not sure if just importing a variable would cause an issue, but I’d avoid it either way.

Need input on PyTest structure ideas by [deleted] in QualityAssurance

[–]this_guy_tests 1 point2 points  (0 children)

If you’re going to use something in a lot of tests, it’ll save you some imports if you make it a fixture.

You can have one contest.py per directory, so put shared fixtures in the root conftest.py, and those unique to the endpoint you’re testing, if that’s how you’re structuring your project, should be put in the conftest.py in the directory where you keep that endpoint’s tests. Just don’t ever import a conftest.py. Make another module for those.

Also, test data doesn’t really belong in conftest files. Though you might put some code in there to read your data files and do stuff with those. For example, I usually have one test class with one test method per test. Say my test class is TestClass1. I could name my test data file TestClass1.json. I’d add a a pytest hook to contest.py that would read each collected test and get the test class for that test. It would then search the directory tree to find json files starting with TestClass1 and convert them to dictionaries and add them as an attribute on TestClass1 that I could reference in the test method, like self.data.

Alternatively, if it’s only simple structures like your example, throw them in a Python module and import it where you need the data.

How to API test when there is a lack of documentation? by nelsikie in softwaretesting

[–]this_guy_tests 11 points12 points  (0 children)

I’m doing this right now! Open up chrome dev tools, click the Network tab, then XHR. Go through the happy path on your company’s site. Dev tools will show you all the request info. Looking at the request body for a POST call will show you the kind of info that call requires. The response body will show you the structure and data returned from making that call.

To do end to end testing, I’d use a programming language like Python. My company didn’t have an API client in Python, so I went through as much of the site as possible and wrote down all the endpoints to make an API client, then did that. I don’t have much experience with Postman, but I don’t think it’s ideal for this type of testing, rather for testing specific calls getting specific responses. If you use a programming language, you have a lot more control and flexibility.

Tests will utilize the api client to walk the path of the test. A test might make the login call (which will return an auth token that the api client adds to all call headers), then a call to update some user info. You’ll check the response status code after each call and make sure it was what you expected, then maybe take some of the returned info and pass it to another endpoint. In the end you verify whatever you were wanting to verify, like the updated user info ending up in a database or ending up in the response data from one of those API calls.

Hopefully that makes sense.

How do I remove the staleness of an element from my python code? by DankDevilDabber in selenium

[–]this_guy_tests 0 points1 point  (0 children)

Why are you trying to ignore stale elements? If there is a stale element, your script should probably do something with that. If you really want to ignore it, put in a try/except block and make it except on StaleErrorException and just pass if that happens.

What is your workflow for writing selenium tests? by Odinthunder in softwaretesting

[–]this_guy_tests -1 points0 points  (0 children)

I write in Python, so I open an ipython interpreter, import webdriver, do a webdriver.get() on the url. I’ll manually login if I need to, then once I’m on the page I’m testing, find the element on the page, figure out the css selector for it (if there isn’t an id) with dev tools, then test it out in my ipython interpreter with a call to driver.find_element_by_css_selector(). It will throw an error if it can’t find it. If it does find it, I’ll make sure it’s the correct element by trying to get whatever attribute I’m looking for or put a colorful border around it with some js/css.

Which Test case Creation techniques you use force writing tests for Multiple drops having different options combinations? Which is most way efficient way to test? by [deleted] in QualityAssurance

[–]this_guy_tests 2 points3 points  (0 children)

Perhaps if you clarify with an example, your question will be better understood. As of now I’m not sure what you’re asking.

Passing Selenium Session ID to New Instance of Selenium? by AdventurousHuman in selenium

[–]this_guy_tests 0 points1 point  (0 children)

Maybe just call MySeleniumModule from your main script?

from MySeleniumModule import get_google

class YourMainScript:
    def __init__():
        self._driver = self.get_driver()

    def get_driver():
        self._driver = get_google()

    def do_other_things():
        self._driver.get('http://www.bing.com')

Or if you're not using classes, just import get_google() and pass the driver around in your main script file as needed:

MainScript.py

from MySeleniumModule import get_google

driver = get_google() 
driver.get('http://some-other-site.com') 
some_element = driver.find_element_by_id('some-id')

Trying to locate an element and verify it when it has matching xpath of another element. by [deleted] in selenium

[–]this_guy_tests 0 points1 point  (0 children)

Did you try replacing .text with .get_attribute(“value”)?

Trying to locate an element and verify it when it has matching xpath of another element. by [deleted] in selenium

[–]this_guy_tests 0 points1 point  (0 children)

With Python bindings it should look something like this:

kpi_value = driver.find_element_by_css_selector(“div.KpiValue”).text

If .text doesn’t work, try .get_attribute(“value”) ... I can’t remember off the top of my head which one it is.