Libraries & Frameworks

I am running this code:

from selenium import webdriver
from `selenium.webdriver.firefox.options` import Options

Setup:

options = Options()
options.add_argument(“–headless”)

def get_results(search_term):

url = “https://www.wikipaedia.org”
browser = webdriver.Firefox(firefox_options=options, executable_path=r”/usr/local/bin/geckodriver”)
browser.get(url)
search_box = browser.find_element_by_id(“query”)
search_box.send_keys(search_term)
search_box.submit()

try:

links = browser.find_elements_by_xpath(“//ol[@class=’web_regular_results’]//h3//a”)

except:

links = browser.find_elements_by_xpath(“//h3//a”)

results = []

for link in links:

href = link.get_attribute(“href”)
print(href)
results.append(href)

browser.close()

return results

I’m getting error messages:

Traceback (most recent call last):
File “search_items.py”, line 37, in <module>
get_results(“dog”)
File “search_items.py”, line 13, in get_results
search_box = browser.find_element_by_id(“query”)
File “/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py”, line 351, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File “/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py”, line 955, in find_element
‘value’: value})[‘value’]
File “/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py”, line 312, in execute
self.error_handler.check_response(response)
File “/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py”, line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id=”query”]

I have tried to solve but it is beyond me.
Any help would be greatly appreciated.

I have a scenario, where I want to Assert the UI is displaying ‘Active’.
When debugging the assertion, I am trying different methods.
This is what I started with:
Assert.IsTrue(webdriver.Text.Contains(“Active”))

but it is throwing an exception;
Assert.IsTrue failed

Any recommendations for properly verifying, that the UI displays Active?
Picture attached for reference.

Let’s learn how to compose multiple animations running at different speeds by creating a 2001: A Space… Source: Read More 

Let’s make a game! We’ll combine all of our newfound skills to build Prong (Prompts + Pong),… Source: Read More 

I have Jquery calender in my application. I have task to select dates from different months using Selenium, but I can do only previous month and forward month. Actually I need to select dates from random months by specifying the date and month as input. If there is a way to achieve it let me know.

**My code for Selecting Previous Month date.**

public static void Date_Picker(String datetoselect,String Xpath,String month) {
// Click on the Given Calender Button
driver.findElement(By.xpath(Xpath)).click();

driver.findElement(By.xpath(“//div[@id=’ui-datepicker-div’]/div/a[1]”)).click();

WebElement Month = driver.findElement(By.xpath(“//div[@id=’ui-datepicker-div’]/div/div[@class=’ui-datepicker-title’]/span”));
String Month_Message = Month.getText();

if(Month_Message.contains(month))
{
WebElement dateWidget = driver.findElement(By.className(“ui-datepicker-calendar”));

List<WebElement> rows=dateWidget.findElements(By.tagName(“tr”));

List<WebElement> columns=dateWidget.findElements(By.tagName(“td”));

for (WebElement cell: columns){

if (cell.getText().equals(datetoselect)){

cell.findElement(By.linkText(datetoselect)).click();
break;

}
}
}

We are trying to get our automated webtests working independently of what version of Chrome we’re using. These automated tests work as follows:

We have a Karaf container agent running as a service;
Karaf starts an ant script, which in turn starts another ant script. The first ant script is part of the automation tool we use (our own product) and the second ant script is the actual script that starts our testng webtests;
TestNg, during the startup, starts the ChromeDriver in the following way using the bonigarcia Webdrivermanager library:

WebDriverManager.chromedriver().setup();
// webDriver = new ChromeDriver();
ChromeOptions options = new ChromeOptions();

// ChromeDriver is just AWFUL because every version or two it breaks unless you pass cryptic arguments
//AGRESSIVE: options.setPageLoadStrategy(PageLoadStrategy.NONE); // https://www.skptricks.com/2018/08/timed-out-receiving-message-from-renderer-selenium.html
options.addArguments(“–enable-automation”); // https://stackoverflow.com/a/43840128/1689770
options.addArguments(“–headless”); // only if you are ACTUALLY running headless
options.addArguments(“–no-sandbox”); //https://stackoverflow.com/a/50725918/1689770
options.addArguments(“–disable-infobars”); //https://stackoverflow.com/a/43840128/1689770
options.addArguments(“–disable-dev-shm-usage”); //https://stackoverflow.com/a/50725918/1689770
options.addArguments(“–disable-gpu”); //https://stackoverflow.com/questions/51959986/how-to-solve-selenium-chromedriver-timed-out-receiving-message-from-renderer-exc
options.addArguments(“–window-size=1920,1080”);
options.addArguments(“–start-maximized”);
options.addArguments(“–disable-extensions”);
options.setExperimentalOption(“useAutomationExtension”, false);
options.addArguments(“–bwsi”);
options.addArguments(“–user-data-dir=”+ System.getProperty(“test.web.chrome.data.dir”) +”/user-data-dir”);
options.addArguments(“–disk-cache-dir=”+ System.getProperty(“test.web.chrome.data.dir”) +”/disk-cache-dir”);
try {
File logFile = new File(System.getProperty(“test.web.chrome.data.dir”).replace(“/”, “\”) + “\logs\chromedriver.log”);
logFile.getParentFile().mkdirs();
logFile.createNewFile();
boolean verbose = System.getProperty(“test.web.webdriver.verbose”).equals(“true”);
ChromeDriverService driverService = new Builder().withVerbose(verbose).withLogFile(logFile).build();

webDriver = new ChromeDriver(driverService, options);
} catch (IOException e) {
LOGGER.error(e);
webDriver = new ChromeDriver(options);
}

The problem we have is that if the Karaf agent is running as the LOCAL_SYSTEM account (which is the default user when creating a new service), the Chromedriver can’t start Chrome with the error:

unknown error: cannot create temp dir for unpacking extensions

After some googling and testing, I’ve found this is because when starting the ChromeDriver, it tries to create a temporary folder for unpacking extensions in the user temp directory, which fails because the LOCAL_SYSTEM account doesn’t have a user directory.

I can work around the issue by making the service run as a LOCAL_SERVICE account, which does have a user directory, but we’ve found that some other scripts that run on this Karaf agent give problems when running as LOCAL_SERVICE (mainly older software integrations that we can’t easily upgrade), so ideally I’m hoping for a solution that makes LOCAL_SYSTEM work.

Is there a way to fix the temp dir problem that the Chromedriver has when attempting to start Chrome from a LOCAL_SYSTEM service?

In my college, I learned about Integration testing in which we combine the whole code together and then test it at once after we are done with unit testing.

A few days back, I heard about Jenkins, which says it does Continuous Integration Testing. I read about it and learned that it means that a developer pushes his/her code several times a day to Jenkins for testing instead of sending the code at the end of the day.

I was confused so I went to read about it from Wikipedia but it didn’t help. I read the two links below

Integration testing

Continuous integration

ELI5

What does this all mean?

What is the difference between Regular Integration Testing and Continuous Integration Testing?

How do I find the element with text “Jessica” based on “3000” displaying in the web page using xpath?
I’m getting …not a valid xpath error.
<div>
<span><b>Jessica</b></span>
<br>
<label>Total Wealth ($):</label>
<p>3000</p>
</div>

I tried this
RichestPersonName = browser.find_element_by_xpath(“//p[text()=’3000′] .. /span”).text

but it shows
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //p[text()=’3000′] .. /span because of the following error:
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//p[text()=’3000′] .. /span’ is not a valid XPath expression.

Is there any mobile cloud testing service for Android offering enhanced location capabilities? My requirements are:

Playback of recorded GPS/location data
GPS data needs to be provided as ‘real’ data, not as (recognizable) mock data
ARM only app, so emulators are probably not an option

I haven’t found a service yet that offers location capabilities beyond setting a static location before each test run. Is there any service out there that meets my requirements?

I have a small confusion about decision table testing. We basically use decision tables to arrive at various possible combinations and then decide what conditions need to be tested and what need not be tested. But how decision table will help in checking invalid conditions? How do we decide how many invalid conditions have to be tested?

Assume I have below decision table. The requirement says if Blower State is OFF, AC request state shall be OFF and Air Condition state shall be OFF. Ambient temperature condition in this case is don’t care. So obviously I need not test with more than one set of data when blower state is OFF. That is why I have considered only one case for blower state OFF condition.

Similarly if AC User Request State is OFF, temperature condition is don’t care. So I have put only one case with AC user request OFF.

So totally I arrived at 4 test cases instead of 8 test cases, considering all combinations.

Now my question is: To check the robustness of the system, don’t we need to keep the blower in OFF state and (Ambient temperature > user request temperature) and test that Air conditioning system is OFF?

Similarly don’t we need to keep the ambient temperature > user request temperature and test for air conditioning system when AC User request is OFF?

There may be several other negative testing scenario like this. How do we select negative test scenario also using decision table?

x in below table indicates don’t care condition.

Quick commerce is revolutionizing the FMCG and eCommerce industries by enabling rapid delivery and enhancing customer experience. The blog discusses how this transformation is driven by integrating advanced technologies, like cloud computing, and leveraging local warehouses for faster service. As businesses adopt QCommerce platforms such as Amazon Prime Now and DoorDash, they see significant sales and market dynamics changes.
The post How Quick Commerce is Transforming FMCG and eCommerce Sectors? first appeared on TestingXperts.

Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of ‘C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.21.1.apk’. Original error: Could not find ‘apksigner.jar’ in [“C:\Users\Rana Hamza\Desktop\sdk-tools\platform-tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\emulator\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\cmdline-tools\latest\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\apksigner.jar”]. Do you have Android Build Tools installed at ‘C:UsersRana HamzaDesktopsdk-tools’?
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘RANA’, ip: ‘192.168.10.4’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘15.0.2’
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of ‘C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.21.1.apk’. Original error: Could not find ‘apksigner.jar’ in [“C:\Users\Rana Hamza\Desktop\sdk-tools\platform-tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\emulator\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\cmdline-tools\latest\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\apksigner.jar”]. Do you have Android Build Tools installed at ‘C:UsersRana HamzaDesktopsdk-tools’?
at getResponseForW3CError (C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolerrors.js:804:9)
at asyncHandler (C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolprotocol.js:380:37)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘RANA’, ip: ‘192.168.10.4’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘15.0.2’
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:95)
at Calculator.main(Calculator.java:30)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:186)
… 13 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of ‘C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.21.1.apk’. Original error: Could not find ‘apksigner.jar’ in [“C:\Users\Rana Hamza\Desktop\sdk-tools\platform-tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\emulator\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\cmdline-tools\latest\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\apksigner.jar”]. Do you have Android Build Tools installed at ‘C:UsersRana HamzaDesktopsdk-tools’?
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘RANA’, ip: ‘192.168.10.4’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘15.0.2’
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of ‘C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.21.1.apk’. Original error: Could not find ‘apksigner.jar’ in [“C:\Users\Rana Hamza\Desktop\sdk-tools\platform-tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\emulator\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\cmdline-tools\latest\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\tools\bin\apksigner.jar”,”C:\Users\Rana Hamza\Desktop\sdk-tools\apksigner.jar”]. Do you have Android Build Tools installed at ‘C:UsersRana HamzaDesktopsdk-tools’?
at getResponseForW3CError (C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolerrors.js:804:9)
at asyncHandler (C:UsersRana HamzaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolprotocol.js:380:37)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
… 18 more

In this episode, we’ll start building out a fully functional datatable in the terminal. This will teach… Source: Read More 

We’ll continue building out our datatable app, adding functionality that allows us to search records and jump… Source: Read MoreÂ