Is there a away to get the element input#fakebox-input and locate it. I was thinking using By.cssSelector or By.xpath, but I don't know how I can include input#fakebox-input
Please give more details when asking questions, not sure what is the ask here ?
If you want help creating xpath or CSS may be show the developer console(f12), anyway , if I go to google and inspect the search, there is an input of a class, based on that, this xpath works, so if you have something similar, replace glFYF gsfi with your class name --
//input[contains(#class,'gLFyf gsfi')]
Related
I am working on a fairly large project. I need to find all LOV's in a single application and modify them. The application has about 4 projects. There might be about 300 LOV's. Is there an easy way to search for these? Could I regex this? Is there a way to get a data model diagram of all LOV's.
Any response is appreciated. Thanks in advance.
A LOV is defined by one or more tags depending on the kind of LOV (select one choice, combobox, input select one choice,...).
You can use any tool that can look for text inside files to search for specific tags.
As you did not tell us the framework you use I give you a sample for the tag ADF selectOneChoice uses:
af:selectOneChoice
So you can search the projects folders for all files containing this text. As you tagged the question with JDeveloper, you can use JDevs Find->'Find in Files...' menu option. In the dialog you get, you enter the right data where to look (scope) and what to look for(Search Text). There are more options you can use to get faster and better results. Click on the '?' button to get more help on how to use this feature.
I'm new to Selenium.
I have been looking all the ways possible to resolve this problem (at this point I think it is just unsolvable) I have a web page (can't share) with this input:
/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td/div/iframe/#document/html/body/div[2]/div/iframe/#document/html/frameset/frame/#document/html/frameset/frameset/frameset/frame/#document/html/body/div/form/table/tbody/tr[2]/td[2]/input
(As you can see the structure has a mix of frames, iframes and framesets; some of them have id and other names some none)
The problem is that Selenium will not find the element by any method I
have tested
. First I tried with a simple driver.findElement(By.all of them)
After they didn't work I start looking on the web and I couldn't find why I couldn't get a handle of this.
It is the only input in the web page and has an id as attribute, so it should be easy.
This is the class where I have been trying to make it work, If you want to check my unsuccessful work I focused my last efforts on the attempt number 8.
As you can see I have been trying to obtain it by several ways, the frames really seemed an issue but it was not them, nor the waiting.
Is it really no way of getting this element? Is it one of those cases
where Selenium can't automate? Or it is that I'm missing something.
object IS visible and there is not even a scroll bar, the whole page fits in the screen perfectly, Xpath was one of the first choices I tested, didn't work
Thank you in advance.
I don't know if this is the problem, but is the element you trying to use visible or you need to scroll in order to view it? If it's not visible try using this to scroll a little bit :
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollBy(0,1000)");
Another possible solution is to try use the absolute xpath instead of relative. There are several tools to find the absolute xpath of an element in an html page. Then you can use
driver.findElement(By.xpath(absoluteXpath));
After a lot of try I realized that selenium was switching to a different frame at the last switchTo. This is probably a bug, but I modified the way I was getting the last switch to to instead of
var wait = (new WebDriverWait(driver, secsToWait));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameNameOrId));
To
driver.switchTo().frame(driver.findElement(By.xpath("//frame[#"+attribute+"='"+frameNameOrId+"']")));
So it finally worked and obtained the input normally.
I am working with JavaSE and Selenium WebDriver within Chrome. My task is to find a set of input fields and do stuff with them. The issue is that I have to do stuff in the presented order they are available on the web page.
So I would find them via XPATH, because that's what works in the given web page. Let's say that I have a set of inputs on the following path: .../form/div/div/div
However for reasons I cannot say, certain type of input fields (such as text and numbers) are in the following path: .../form/div/div
The problem is that one set of the inputs are one div 'deeper' than the others, so when I save them to a List<WebElement> with driver.findElements, i can't really save their order.
I thought of finding the inputs with id, but the id names have a space in it which Selenium apparently dislikes. I am not sure if relative XPATH could be of help in this case.
Your comments are appreciated.
I made the mistake of not reading enough about XPATH. What I was looking for was the 'and' operand within an xpath expression. If you are a beginner like me, please read about it on w3schools.
Basically the following code solved my issue, as a workaround:
driver.findElements(By.xpath("//input[#required=''] | //select[#required='']"));
I would like to programmatically issue a click on a web page and download the CSV file from the website. I'm trying to implement this logic with HtmlUnit library. The code that I'm trying to use:
HtmlPage historicalDataHtmlPage = webClient.getPage("https://finance.yahoo.com/quote/GOOG/history?p=GOOG");
HtmlPage downloadHtmlPage = historicalDataHtmlPage.getAnchorByText("Download Data").click();
HtmlUnit seems to have a problem finding this particular element (not sure why - i tested this solution on other websites and it seems to find anchors by text).
Can you please advise how can I fix this error or how can I refer to the Download Data element in any other way?
Thank you.
Please go through the links mentioned by #pvg and modify your question as per the guidelines.
Having said that, have you tried using getAnchors() which returns a list List<HtmlAnchor> and see what is the text you are getting inside the tag you want. Maybe there are other elements which do not match your text assumption of "Download Data".
Would have posted this as a comment but lack the reputation to do so.
Looks like the page starts with minimal content and adds you anchor later by doing some background requests.
Try to wait some seconds before you start searching for the anchor.
Also it is a good idea to use Page.asXML() to get an idea of the current status of the page (e.g. before and after the wait to see if something has changed.
I have this code
WebElement element = driver.findElement(By.id("j_idt9:usuario"));
I want to know how I can use XPath to search for a specific ID. In this case, I want to search for the "usuario" portion because the "j_idt9" portion changes. I know that it can be done using a CSS Selector but I am required to use XPath.
You should tell your professor that CSS selectors are not just for classes... and if s/he really did say that, they should be embarrassed and go do some reading. They can start with these two references:
https://www.w3.org/TR/selectors/#selectors
https://saucelabs.com/resources/articles/selenium-tips-css-selectors
If you have to use XPath, it would look like
"//*[ends-with(#id, 'usuario')]"
You'd be better off using a CSS selector because it's faster and has better, more consistent browser support. It would look like
"[id$='usuario']"
In general, your locator strategy should look like this...
By.id
By.linkText, By.partialLinkText
By.cssSelector
then as a last resort, By.xpath
By.xpath should only be used when the other methods won't work. Cases like you need to find an element by the text it contains or you have to do some parent/child shifts that CSS can't do.