Development

I am able to modify http request header using BrowserMobProxy, the same way explained

https://sqa.stackexchange.com/a/37318/9043

But, the problem I am having at the moment is, that I am executing my scenarios on dev/local/playpen environment (environment before System integration testing). And to open the website on this environment needs proxy to set.

When I set my proxy then it fails to modify header and apply the proxy. When I comment the proxy part then it easily modifies the header.

BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.start(0);
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

proxy.addRequestFilter((request, contents, messageInfo)->{
request.headers().add(“some-header-attribute”, “RandomeValue”);
System.out.println(request.headers().entries().toString());
return null;
});

String _host = Utils.getConfigValue(“proxy.host”);
String _port = Utils.getConfigValue(“proxy.port”);

seleniumProxy.setProxyType(Proxy.ProxyType.MANUAL);
seleniumProxy.setHttpProxy(_host + “:” + _port);
seleniumProxy.setSslProxy(_host + “:” + _port);
seleniumProxy.setFtpProxy(_host + “:” + _port);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

String proxyOption = “–proxy-server=” + seleniumProxy.getHttpProxy();
options.addArguments(proxyOption);

I’m trying to use a custom profile in Firefox with an add-on, I can open the profile, launch URL, I even see the add-on icon on top bar but is always set into the disabled mode, I need to set it to active all time. The add-on is ‘anonymous’
below is what I did, but no success.

public class SeleniumScript {
static WebDriver driver;
public static void main(String args[]) throws Exception {
System.setProperty(“webdriver.gecko.driver”, “E:\Library\geckodriver-v0.21.0-win32\geckodriver.exe”);
ProfilesIni profile2 = new ProfilesIni();
FirefoxProfile profile3 = profile2.getProfile(“AutoProfile”);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(profile3);
File file = new File(“C:\Users\xxx\AppData\Roaming\Mozilla\Firefox\Profiles\vjo848oc.AutoProfile\extensions\client@anonymox.net.xpi”);
profile3.addExtension(file);
profile3.setPreference(“extensions.anonymox.currentVersion”, “4.1”);
driver = new FirefoxDriver(firefoxOptions);
String baseURL = “http://abc.com”;
driver.get(baseURL);
driver.manage().window().maximize();
}
}

I have an HTML element with a disabled attribute that is either true or `false, like:
<div class=”row” disabled=”false”>

or
<div class=”row” disabled=”true”>

I thought this would be straightforward to verify in Cypress by doing something like:
cy.get(“div.row”).should(“have.attr”, “disabled”, “false”)

However, when I tried that the test fails because Cypress reports that the disabled attribute of the element does not have the value “false” but instead has the value “disabled”.
If I open the browser inspection tool I can verify that the attribute is shown as I’ve written above. Any idea what is going wrong?

<select id=”SelectedCustomerRoleIds” multiple=”multiple” name=”SelectedCustomerRoleIds” data-role=”multiselect” aria-disabled=”false” style=”display: none;” xpath=”1″>
<option value=”1″>Administrators</option>
<option value=”2″>Forum Moderators</option>
<option value=”4″>Guests</option>
<option value=”3″ selected=”” style=””>Registered</option>
<option value=”5″>Vendors</option></select>

I have tried the following code to deselect option 3 – Registered and select option 4 – Guests.
WebElement element= driver.findElement(By.id(“SelectedCustomerRoleIds”)):
Select select = new Select(element): select.deselectByValue(“3”):
select.selectByValue(“4”)

I’m using SoapUI to test REST webservices and I’m stuck on an issue.
I have a json object, called coverages, which consists of one or more other objects, it looks something like this (example with 2 coverages):
“coverages” : [
{
“CovNr” : 123,
“CovDesc” : “My coverage”
},
{
“CovNr” : 456,
“CovDesc” : “Another coverage”
}
]

The thing is, sometimes there is one coverage, and sometimes there are multiple. This means I need the coverages object to be variable, and have either one or more coverages as its body, depending on # of coverages.
Since the number of coverages isn’t always the same I can’t use properties for the CovNr and CovDesc attributes. Also I can’t just always add like three and leave two empty if only one is used (can’t have empty attributes).
I tried to set a coverages property using groovy script, which consisted of the entire body of the coverages object, but that didn’t work (I’m guessing the editor can’t parse an entire part of a request from a property).
Example of what I tried:
in groovy:
def coverages = “[ { “CovNr” : 123, “CovDesc” : “My coverage” }, { “CovNr” :456, “CovDesc” : “Another coverage” }]”
testRunner.testCase.setPropertyValue(“coverages”, coverages)

in request body:

“coverages” : “$(#TestCase#coverages)”,

This didn’t work.
Is there another way to add a variable number of coverages to my request body?