Change Selenium Grid default URL - selenium

I am using Selenium Grid 4 and default url is ie. http://localhost:4444. I need to change it to something like http://localhost:4444/hub so the UI is accessible on http://localhost:4444/hub/ui. Is there any way how to achieve it?
Thanks

Related

Selenium Inspect : 2 divs same footer

I am using Selenium IDE to conduct testing my website.
Please refer to the above image. I have 2 windows one over the other and I need to get the xpath of the 2nd footer that is the last in the image.
When I use Selenium it picks but does not work as expected. In a situation like this how do I know the xpath and which to use in Selenium.
Thanks
You can do this to access the 2nd element with that xpath
driver.find_element(BY.XPATH,"(//div[#class='footer'])[2]")
If you need any of those individual values.
I would use link_text since they all have different text values and are all of a tags.
driver.find_element(BY.LINK_TEXT,"Upload")

Identifying ExtJS elements with selenium webdriver

I am having handling a drop down button in EXTJS application which i am trying to automation with selenium web driver.
clicking on the image i will get a list of elements in the form of 's
to click select from
Please help me how i can device a xpath to click this image, which i should not use "id" (as its extjs it might vary every now and then).
if there are any selector i can use for extjs please suggest. Thanks for your help.
<DIV id=ext-gen2337 class=x-form-field-wrap style="WIDTH: 0px"><INPUT id=ext-gen2023 class=" x-form-text x-form-field" style="WIDTH: 297px" readOnly size=24 value="Clients with pending exceptions" name=ext-gen2023 autocomplete="off"><IMG id=ext-gen2338 class="x-form-trigger x-form-arrow-trigger" src="https:REDACTED/com.ssc.epw.gui.EPWHome/clear.cache.gif">
Try below XPath to match required img element:
//input[#value="Clients with pending exceptions"]/following-sibling::img
So if you want to start testing ExtJS app and you don't want to use the best solution for this such as Sencha Test or Bryntum Siesta.
The best way to approach this is to write you own layer between the ExtJS components and the html dom of the site.
You can see more info in my answer here https://stackoverflow.com/a/41718879/1768843
But what you need to do is to use the Ext.Component.Query, with Selenium you can execute the javascript code on the site. So you execute the ext query and you pass there the Ext selector - for example button[text=something] or panel[name=mainPanel] simply any ExtJS component selector. This will return you the ExtJS object and with it you can simply call .getDom() or .getId() which will return you the actual dom or id used in the HTML. Next you can simply use the webdriver functions for clicking (or something) on the HTML elements in the site.
^^ You need to do this because the ExtJS framework can generate the HTML every-time little bit differently. For example you add new container or you upgrade your ExtJS version and the HTML is changed and your test can stop working. But if you call the Ext components as log as the Ext source code is still the same your tests will be always working.
But doing this is quite a hassle and lot of work. It's much better to use prepared solutions such as Sencha Test where everything is already prepare for testing ExtJS apps.
I would do something like this:
driver.findElement(By.xpath("//div[contains(#class, 'x-form-field-wrap')]//img"));
or
driver.findElement(By.xpath("//img[contains(#src, 'https://REDACTED/com.ssc.epw.gui.EPWHome/clear.cache.gif')]"));

How to modify css attribute without using javascript in Selenium Webdriver

Is there a way to modify css attribute without using selenium's driver.execute_script?
No, there is not.
Selenium is meant to mimic user interactions with the browser. Setting CSS attributes is not part of the normal user interaction with a browser.
If you wish to modify a CSS attribute, you will need to use execute-script.

How to work with iframe which is part of a webpage but not getting identified through webdriver?

I am trying to automate a webpage using webdriver,here i am struck with a iframe,which i dont know how to handle.
While i choose css for the iframe by selecting with ,it gives me #xEditingArea
again if I search the same iframe using the css or id,it is not identifying anything.
I tried everything
I want to write some message with the message body which is iframe.
Can anyone guide me how to handle this?
Thanks in advance.
If it is only one iFrame on your website you could try to access it with XPath and the tagname.
Directly accessing iframes is not possible, it has its own DOM elements and we have to switch to that particular frame and then perform the actions you want.
To select the iframe you want to work with, do:
driver.switchTo().frame("frame1");
Now, your driver set to work with the DOM the iframe one.
It's important to remember that maybe switching "back" will be needed. It's done like this:
driver.switchTo().defaultContent();
Using Python Selenium WebDriver, you can access a frame using:
from selenium import webdriver
browser = webdriver.Firefox()
browser.switch_to_frame("fame_name_or_id")
If you want to confirm that the frame was access correctly, just print out the page contents using:
print browser.page_source

How to get the content of CKeditor using WebDriver

I'd like to be able to test the content in CKeditor using webdriver.
However there are some hurdles; firstly CKeditor uses Iframes, and there are several Iframes on the page, so not sure how to switch reliably to it using WebDriver as they don't have specific names.
In addition, the content inside the editor is within a <body></body> tag inside the iframe. I'm not sure how to get WebDriver to return the content reliably.
Has anyone actually tried to do this in their tests? If so, how did you achieve it?
Thanks.
You can use the CKEditor api and execute javascript. Not sure which selenium driver you are using but here is the java script you can use to get the HTML for:
"return CKEDITOR.instances['youreditoridhere'].getData();"
u may refer this
http://bharath-marrivada.blogspot.com/2012/03/fckeditor-switch-activeelement.html
hopes this help ;D