I am doing Selenium Testing using Jmeter Script. I want to select a value in dropdown but it takes a few seconds after the page loads for all the options to fill in the dropdown. I want to wait until those options are filled.
I tried below methods but they don't seem to work:
var waitPropHist = new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 20);
Thought using above, I can just put a delay in my testing but that didnt seem to work.
Could anyone please guide me on this? I want to either put a delay in script or just wait until the dropdown size increases.
This line doesn't do anything per se, you need to call wait.until() function and provide either one of the ExpectedConditions or your custom condition implementation.
Example:
var wait = new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 25)
wait.until(org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable(org.openqa.selenium.By.xpath("//a[contains(text(),'More information')]")))
More information: The WebDriver Sampler: Your Top 10 Questions Answered
Related
I am attempting web automation with a platform called Robocorp using the Selenium library.
When I run my program, I have no issues until I encounter this page where I am trying to get the program to click on the icon that says SQL.
I want the <a> element with the #href attribute.
Here are some (of many) XPaths I have tried that have all failed:
xpath://a[contains(#href,'sql_form.jsp')]
xpath://*[text()='SQL']
xpath://a[#target='frame2]
Snapshot of the element:
I circled the element in red ^^^
I cannot get the selector to be recognized on this page. I have tried adding delays, waiting until the element is active, waiting until the element is visible, etc.
Nothing seems to work.
Here is an image of the elements I am trying to select.
(The link in the href element takes me to the page I am trying to access).
I thought that the third one would for sure work but is still failing.
I am using a platform called Robocorp which only needs the raw selector to work (CSS or XPath)
I was unaware that iframe needed to be handled differently or that it even existed
https://robocorp.com/docs/development-guide/browser/how-to-work-with-iframes
I first needed to switch frames.
To identify the element with text as SQL you can use you can use either of the following locator strategies:
Using Wait Until Element Is Visible:
Wait Until Element Is Visible xpath=//a[starts-with(#href, 'sql_form.jsp') and #target='frame2']/font[text()='SQL'] 10 seconds
Using Wait Until Element Is Enabled:
Wait Until Element Is Enabled xpath=//a[starts-with(#href, 'sql_form.jsp') and #target='frame2']/font[text()='SQL'] 10 seconds
References
You can find a couple of relevant detailed discussions in:
How to click a row that has javascript on click event in RIDE
Robot Framework: Wait Until Element Is Visible vs. Element Should Be Visible, which one is better to use?
I am not sure why keep failed with Response Code 500 on my script. Please is my sample code and error messages. Please kindly advise. Many thanks.
Error Messages:
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
1612415604534,36638,jp#gc - WebDriver Sampler,500,"javax.script.ScriptException: org.openqa.selenium.ElementNotInteractableException: element not interactable
(Session info: chrome=88.0.4324.146)
Sample Code:
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;
WDS.sampleResult.sampleStart();
WDS.browser.get("https://uat-testing.com/");
sleep(10000);
WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[#type='text']")).sendKeys("xxxx#testing.com");
WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[#type='password']")).clear();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[#type='password']")).sendKeys("xxx#xxxx");
WDS.browser.findElement(org.openqa.selenium.By.xpath("//button/span")).click();
sleep(20000);
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[10]/li/span")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[16]/li/span")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[3]/li/span")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[5]/div/div/div")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//ul[contains(#id,'dropdown-menu-')]/li")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("(//button[contains(#type,'button')])")).click();
sleep(30000);
WDS.sampleResult.sampleEnd();
This ElementNotInteractableException means that the element you're trying to work with cannot be used by WebDriver
Thrown to indicate that although an element is present on the DOM, it is not in a state that can be interacted with.
Most probably it's "covered" by other DOM element so the options are in:
Use Explicit Wait for "waiting" until the element can be accessed (by the way you should also consider replacing your "sleeps" with the explicit waits as it's kind of a performance anti-pattern)
Instead of trying to work with particular this element you might want to interact with the one which hovers it, to wit change locator to another one
And finally you can use JavaScript Executor in order to perform the "click" by means of JavaScript
More information on WebDriver Sampler: The WebDriver Sampler: Your Top 10 Questions Answered
I have no idea what is wrong in the simple code i have written to select a value from the dropdown. I have been watching other tutorials and code samples and i dont find any mistake in my code. Could someone please help me? I have tried running my code in Chrome as well as Mozilla(on two different OS) but still the issue exists.I am posting attachment of the html as well as selenium code.
Also, i am sure the problem is not because i have used wait because even if i comment that line or use it after loading the web page, the issue is there.
HTML
Selenium
Why don't you try clicking on the dropdown and then selecting the value.
tp.click();
and then
Select dropdown = new Select(tp);
dropdown.selectByValue("2");
new Select (driver.findElement(By.id("custtitle"))).selectByValue("2");
OR
new Select(driver.findElement(By.id("custtitle"))).selectByVisibleText("Mrs.");
Alright, so I thought this would be easy but I've spend a few hours searching and trying different methods with no avail. I need to tell protractor to only click on a button when it is present. To water it down basically my test checks if a certain value is present on a page. The page can be in one of two states, automatic mode, which contains my value I'm testing or design mode, which contains other values which are irrelevant for this test. If its in design mode, we first need to click on automatic mode which produces a prompt asking us if we are sure we want to continue and switch to automatic mode - this prompt contains the continue button I need to check for and click. If the page is already in automatic mode however, I don't need to perform this check, I can proceed to validate weather or not my value is present. Basically I tried this:
if (continueButton.isDisplayed()) {
continueButton.click();
}
what happens I get a "No element found using locator:..." error. I tried a few different ways such as using isElementPresent, and some of the expected condition options but more or less I get the same results. How can I achieve this scenario where my test checks if a button is present and clicks it, and if it isn't present continues with the test.
You can achieve this by using promises.
continueButton.isDisplayed().then(function (isDisplayed) {
if(isDisplayed){
continueButton.click();
}
});
browser.wait() and elementToBeClickable Expected Condition is exactly what might help:
var EC = protractor.ExpectedConditions;
browser.wait(EC.elementToBeClickable(continueButton), 5000);
continueButton.click();
I am trying to make WatiN attach to an IE popup window (IE 10).
This popup contains a frameset --> a single frame --> a pdf document.
My goal is to save this pdf to my disk.
Dim winExists = IE.Exists(Of IE)(Find.ByUrl(Function(url) url.Contains("__ADFvDlg")))
If winExists Then 'this evaluates to true
Dim win = IE.AttachTo(Of IE)(Find.ByUrl(Function(url) url.Contains("__ADFvDlg"))) ' Timeout while waiting for frame document becoming available
End If
1) I have tried using the above code inline or in a STA thread
2) When coded inline, its parent thread is also STA
3) I have tried to increase the default timeout to 8 minutes, same result after 8 minutes have passed
There is no other option for me than to parse this particular popup, since it is a site built with Oracle ADF and, apart from the fact that it is A MESS, it is very strange at times...this popup has a URL that somehow works only once. If I try to use it in another window, no pdf is returned. The same happens when I refresh the popup.
I cannot fetch the PDF in the Temporary Internet Files since it is not there (I suppose this is because the website works under SSL).
Any guidelines or solutions even outside WatiN's scope is more than welcome since I've hit a brick wall.
Technologies: VS2012, WPF
Thanks a lot in advance.
I found it easiest when I tried the same thing by making the pop-up show up as a new tab. That way I could attach to it's URL. From there I would use
File.WriteAllText(fileName, responseDownLoad.Content.ReadAsStringAsync().Result);
Where responseDownload will be a HttpResponseMessage